Skip to content

Navigation Menu

Sign in
Appearance settings

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

Commit d373cd5

Browse filesBrowse files
committed
Add a PdoStore in lock
1 parent f96753b commit d373cd5
Copy full SHA for d373cd5

9 files changed

+506
-21
lines changed

‎src/Symfony/Component/Lock/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.2.0
5+
-----
6+
7+
* added the PDO Store
8+
49
3.4.0
510
-----
611

‎src/Symfony/Component/Lock/Store/MemcachedStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/MemcachedStore.php
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct(\Memcached $memcached, int $initialTtl = 300)
5757
*/
5858
public function save(Key $key)
5959
{
60-
$token = $this->getToken($key);
60+
$token = $this->getUniqueToken($key);
6161
$key->reduceLifetime($this->initialTtl);
6262
if (!$this->memcached->add((string) $key, $token, (int) ceil($this->initialTtl))) {
6363
// the lock is already acquired. It could be us. Let's try to put off.
@@ -80,13 +80,13 @@ public function waitAndSave(Key $key)
8080
public function putOffExpiration(Key $key, $ttl)
8181
{
8282
if ($ttl < 1) {
83-
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1. Got %s.', __METHOD__, $ttl));
83+
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
8484
}
8585

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

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

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

@@ -120,7 +120,7 @@ public function putOffExpiration(Key $key, $ttl)
120120
*/
121121
public function delete(Key $key)
122122
{
123-
$token = $this->getToken($key);
123+
$token = $this->getUniqueToken($key);
124124

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

@@ -144,13 +144,10 @@ public function delete(Key $key)
144144
*/
145145
public function exists(Key $key)
146146
{
147-
return $this->memcached->get((string) $key) === $this->getToken($key);
147+
return $this->memcached->get((string) $key) === $this->getUniqueToken($key);
148148
}
149149

150-
/**
151-
* Retrieve an unique token for the given key.
152-
*/
153-
private function getToken(Key $key): string
150+
private function getUniqueToken(Key $key): string
154151
{
155152
if (!$key->hasState(__CLASS__)) {
156153
$token = base64_encode(random_bytes(32));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.