Skip to content

Commit

Permalink
Merge pull request #5 from srjlewis/master
Browse files Browse the repository at this point in the history
Fix for expiry ttl, as couchbase >= v4, now can use DateTimeInterface for the ttl
  • Loading branch information
Geolim4 authored Jun 14, 2024
2 parents c445d4e + bd11a22 commit 2c93fa3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ protected function driverWrite(ExtendedCacheItemInterface $item): bool
$this->getCollection()->upsert(
$item->getEncodedKey(),
$this->encodeDocument($this->driverPreWrap($item)),
(new UpsertOptions())->expiry($item->getTtl())
(new UpsertOptions())->expiry($item->getExpirationDate())
);
return true;
} catch (CouchbaseException) {
Expand Down
9 changes: 9 additions & 0 deletions tests/Couchbasev4.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
$cache1->set('forkSuccessTestKey1', $value1);
$cache2->set('forkSuccessTestKey2', $value2);

// 1576800000 is the int limit within Couchbase for the ttl before the need to use DateTime
// so using an int like '\time() + 3600' would produce an error, to reproduce the error
// within phpFastCache we need to push the date 1576800001s in the future to overflow the ttl int
if($cache->set('bigTTL', 'test', new DateInterval('PT1576800001S'))) {
$testHelper->assertPass('Set with large ttl succeeded');
} else {
$testHelper->assertFail('Set with large ttl failed');
}

try {
\Phpfastcache\Extensions\Drivers\Couchbasev4\Driver::prepareToFork();
$pid = \pcntl_fork();
Expand Down

0 comments on commit 2c93fa3

Please sign in to comment.