Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[LOCK] Add a PdoStore #27456

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
Sep 4, 2018
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
5 changes: 5 additions & 0 deletions 5 src/Symfony/Component/Lock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.2.0
-----

* added the PDO Store

3.4.0
-----

Expand Down
15 changes: 6 additions & 9 deletions 15 src/Symfony/Component/Lock/Store/MemcachedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(\Memcached $memcached, int $initialTtl = 300)
*/
public function save(Key $key)
{
$token = $this->getToken($key);
$token = $this->getUniqueToken($key);
$key->reduceLifetime($this->initialTtl);
if (!$this->memcached->add((string) $key, $token, (int) ceil($this->initialTtl))) {
// the lock is already acquired. It could be us. Let's try to put off.
Expand All @@ -80,13 +80,13 @@ public function waitAndSave(Key $key)
public function putOffExpiration(Key $key, $ttl)
{
if ($ttl < 1) {
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1. Got %s.', __METHOD__, $ttl));
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
}

// Interface defines a float value but Store required an integer.
$ttl = (int) ceil($ttl);

$token = $this->getToken($key);
$token = $this->getUniqueToken($key);

list($value, $cas) = $this->getValueAndCas($key);

Expand Down Expand Up @@ -120,7 +120,7 @@ public function putOffExpiration(Key $key, $ttl)
*/
public function delete(Key $key)
{
$token = $this->getToken($key);
$token = $this->getUniqueToken($key);

list($value, $cas) = $this->getValueAndCas($key);

Expand All @@ -144,13 +144,10 @@ public function delete(Key $key)
*/
public function exists(Key $key)
{
return $this->memcached->get((string) $key) === $this->getToken($key);
return $this->memcached->get((string) $key) === $this->getUniqueToken($key);
}

/**
* Retrieve an unique token for the given key.
*/
private function getToken(Key $key): string
private function getUniqueToken(Key $key): string
{
if (!$key->hasState(__CLASS__)) {
$token = base64_encode(random_bytes(32));
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.