Skip to content

[Cache] Fix expiration time for CouchbaseCollection #53054

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
Dec 29, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CouchbaseCollectionAdapter extends AbstractAdapter
public function __construct(Collection $connection, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
{
if (!static::isSupported()) {
throw new CacheException('Couchbase >= 3.0.0 < 4.0.0 is required.');
throw new CacheException('Couchbase >= 3.0.5 < 4.0.0 is required.');
}

$this->maxIdLength = static::MAX_KEY_LENGTH;
Expand All @@ -54,7 +54,7 @@ public static function createConnection(#[\SensitiveParameter] array|string $dsn
}

if (!static::isSupported()) {
throw new CacheException('Couchbase >= 3.0.0 < 4.0.0 is required.');
throw new CacheException('Couchbase >= 3.0.5 < 4.0.0 is required.');
}

set_error_handler(function ($type, $msg, $file, $line): bool { throw new \ErrorException($msg, 0, $type, $file, $line); });
Expand Down Expand Up @@ -183,7 +183,7 @@ protected function doSave(array $values, $lifetime): array|bool
}

$upsertOptions = new UpsertOptions();
$upsertOptions->expiry($lifetime);
$upsertOptions->expiry(time() + $lifetime);

$ko = [];
foreach ($values as $key => $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/**
* @requires extension couchbase <4.0.0
* @requires extension couchbase >=3.0.0
* @requires extension couchbase >=3.0.5
*
* @group integration
*
Expand All @@ -36,7 +36,7 @@ class CouchbaseCollectionAdapterTest extends AdapterTestCase
public static function setupBeforeClass(): void
{
if (!CouchbaseCollectionAdapter::isSupported()) {
self::markTestSkipped('Couchbase >= 3.0.0 < 4.0.0 is required.');
self::markTestSkipped('Couchbase >= 3.0.5 < 4.0.0 is required.');
}

self::$client = AbstractAdapter::createConnection('couchbase://'.getenv('COUCHBASE_HOST').'/cache',
Expand All @@ -47,7 +47,7 @@ public static function setupBeforeClass(): void
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
{
if (!CouchbaseCollectionAdapter::isSupported()) {
self::markTestSkipped('Couchbase >= 3.0.0 < 4.0.0 is required.');
self::markTestSkipped('Couchbase >= 3.0.5 < 4.0.0 is required.');
}

$client = $defaultLifetime
Expand Down