@@ -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