| @@ 77-81 (lines=5) @@ | ||
| 74 | file_put_contents($temp, $value); |
|
| 75 | ||
| 76 | // rename the temp file with locking |
|
| 77 | if ($fp = $this->getLock($path)) { |
|
| 78 | $res = rename($temp, $path) && touch($path, time() + $ttl); |
|
| 79 | $this->releaseLock($path, $fp); |
|
| 80 | return $res; |
|
| 81 | } |
|
| 82 | ||
| 83 | // locking failed |
|
| 84 | return false; |
|
| @@ 93-97 (lines=5) @@ | ||
| 90 | public function delete(string $key): bool |
|
| 91 | { |
|
| 92 | $path = $this->getPath($key); |
|
| 93 | if (file_exists($path) && $fp = $this->getLock($path)) { |
|
| 94 | $res = unlink($path); |
|
| 95 | $this->releaseLock($path, $fp); |
|
| 96 | return $res; |
|
| 97 | } |
|
| 98 | return false; |
|
| 99 | } |
|
| 100 | ||