Skip to content

[Cache] Fix calculate ttl in couchbase sdk 3.0 #44060

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
Nov 16, 2021
Merged
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 @@ -27,7 +27,6 @@
*/
class CouchbaseCollectionAdapter extends AbstractAdapter
{
private const THIRTY_DAYS_IN_SECONDS = 2592000;
private const MAX_KEY_LENGTH = 250;

/** @var Collection */
Expand Down Expand Up @@ -123,7 +122,7 @@ public static function createConnection($dsn, array $options = [])

public static function isSupported(): bool
{
return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '3.0', '>=') && version_compare(phpversion('couchbase'), '4.0', '<');
return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '3.0.5', '>=') && version_compare(phpversion('couchbase'), '4.0', '<');
}

private static function getOptions(string $options): array
Expand Down Expand Up @@ -206,7 +205,6 @@ protected function doSave(array $values, $lifetime)
return $failed;
}

$lifetime = $this->normalizeExpiry($lifetime);
$upsertOptions = new UpsertOptions();
$upsertOptions->expiry($lifetime);

Expand All @@ -221,13 +219,4 @@ protected function doSave(array $values, $lifetime)

return [] === $ko ? true : $ko;
}

private function normalizeExpiry(int $expiry): int
{
if ($expiry && $expiry > static::THIRTY_DAYS_IN_SECONDS) {
$expiry += time();
}

return $expiry;
}
}