Classes/RedisLockStrategy.php 1 location
|
@@ 259-265 (lines=7) @@
|
256 |
|
* |
257 |
|
* @return boolean TRUE on success, FALSE otherwise |
258 |
|
*/ |
259 |
|
private function lock() |
260 |
|
{ |
261 |
|
$this->value = uniqid(); |
262 |
|
|
263 |
|
// option NX: set value iff key is not present |
264 |
|
return (bool) $this->redis->set($this->name, $this->value, ['NX', 'PX' => $this->ttl]); |
265 |
|
} |
266 |
|
|
267 |
|
/** |
268 |
|
* Wait for the lock being released |
Tests/test.php 1 location
|
@@ 273-279 (lines=7) @@
|
270 |
|
* |
271 |
|
* @return boolean TRUE on success, FALSE otherwise |
272 |
|
*/ |
273 |
|
private function lock() |
274 |
|
{ |
275 |
|
$this->value = uniqid(); |
276 |
|
|
277 |
|
// option NX: set value iff key is not present |
278 |
|
return (bool) $this->redis->set($this->name, $this->value, ['NX', 'PX' => $this->ttl]); |
279 |
|
} |
280 |
|
|
281 |
|
/** |
282 |
|
* Wait for the lock being released |