Skip to content

Fix for expiry ttl, as couchbase >= v4, now can use DateTimeInterface for the ttl #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading