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