Classes/RedisLockStrategy.php 1 location
|
@@ 228-234 (lines=7) @@
|
| 225 |
|
* |
| 226 |
|
* @return boolean TRUE on success, FALSE otherwise |
| 227 |
|
*/ |
| 228 |
|
private function lock() |
| 229 |
|
{ |
| 230 |
|
$this->value = uniqid(); |
| 231 |
|
|
| 232 |
|
// option NX: set value iff key is not present |
| 233 |
|
return (bool) $this->redis->set($this->name, $this->value, ['NX', 'PX' => $this->ttl]); |
| 234 |
|
} |
| 235 |
|
|
| 236 |
|
/** |
| 237 |
|
* Wait for the lock being released |
Tests/concurrent/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 |