| @@ 63-78 (lines=16) @@ | ||
| 60 | /** |
|
| 61 | * {@inheritdoc} |
|
| 62 | */ |
|
| 63 | public function has(string $name): bool |
|
| 64 | { |
|
| 65 | if (!$this->files->exists($filename = $this->makeFilename($name))) { |
|
| 66 | return false; |
|
| 67 | } |
|
| 68 | ||
| 69 | $cacheData = unserialize($this->files->read($filename)); |
|
| 70 | if (!empty($cacheData[0]) && $cacheData[0] < time()) { |
|
| 71 | $this->delete($name); |
|
| 72 | ||
| 73 | //Expired |
|
| 74 | return false; |
|
| 75 | } |
|
| 76 | ||
| 77 | return true; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * {@inheritdoc} |
|
| @@ 85-99 (lines=15) @@ | ||
| 82 | * |
|
| 83 | * @param int $expiration Current expiration time value in seconds (reference). |
|
| 84 | */ |
|
| 85 | public function get(string $name, int &$expiration = null) |
|
| 86 | { |
|
| 87 | if (!$this->files->exists($filename = $this->makeFilename($name))) { |
|
| 88 | return null; |
|
| 89 | } |
|
| 90 | ||
| 91 | $cacheData = unserialize($this->files->read($filename)); |
|
| 92 | if (!empty($cacheData[0]) && $cacheData[0] < time()) { |
|
| 93 | $this->delete($name); |
|
| 94 | ||
| 95 | return null; |
|
| 96 | } |
|
| 97 | ||
| 98 | return $cacheData[1]; |
|
| 99 | } |
|
| 100 | ||
| 101 | /** |
|
| 102 | * {@inheritdoc} |
|