Classes/RedisLockStrategy.php 1 location
|
@@ 246-252 (lines=7) @@
|
| 243 |
|
* |
| 244 |
|
* @return boolean TRUE on success, FALSE otherwise |
| 245 |
|
*/ |
| 246 |
|
private function lock() |
| 247 |
|
{ |
| 248 |
|
$this->value = uniqid(); |
| 249 |
|
|
| 250 |
|
// option NX: set value iff key is not present |
| 251 |
|
return (bool) $this->redis->set($this->name, $this->value, ['NX', 'PX' => $this->ttl]); |
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
/** |
| 255 |
|
* Wait for the lock being released |
Tests/test.php 1 location
|
@@ 263-269 (lines=7) @@
|
| 260 |
|
* |
| 261 |
|
* @return boolean TRUE on success, FALSE otherwise |
| 262 |
|
*/ |
| 263 |
|
private function lock() |
| 264 |
|
{ |
| 265 |
|
$this->value = uniqid(); |
| 266 |
|
|
| 267 |
|
// option NX: set value iff key is not present |
| 268 |
|
return (bool) $this->redis->set($this->name, $this->value, ['NX', 'PX' => $this->ttl]); |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
/** |
| 272 |
|
* Wait for the lock being released |