| @@ 139-153 (lines=15) @@ | ||
| 136 | * |
|
| 137 | * @return bool|mixed |
|
| 138 | */ |
|
| 139 | protected function retrieve($key) |
|
| 140 | { |
|
| 141 | $value = dba_fetch($key, $this->dba); |
|
| 142 | ||
| 143 | if (false === $value) { |
|
| 144 | return false; |
|
| 145 | } |
|
| 146 | ||
| 147 | // compare the timestamp to the current time when we read the value. |
|
| 148 | if (time() >= substr($value, 0, 10)) { |
|
| 149 | return $this->forget($key); |
|
| 150 | } |
|
| 151 | ||
| 152 | return unserialize(substr($value, 10)); |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * @param string $key |
|
| @@ 49-64 (lines=16) @@ | ||
| 46 | * |
|
| 47 | * @return bool|mixed|null |
|
| 48 | */ |
|
| 49 | protected function retrieve($key) |
|
| 50 | { |
|
| 51 | if (!$this->has($key)) { |
|
| 52 | return null; |
|
| 53 | } |
|
| 54 | ||
| 55 | $cache = file_get_contents($this->path . $key); |
|
| 56 | ||
| 57 | // compare the timestamp to the current time when we read the file. |
|
| 58 | if (time() >= substr($cache, 0, 10)) { |
|
| 59 | $this->forget($key); |
|
| 60 | return null; |
|
| 61 | } |
|
| 62 | ||
| 63 | return unserialize(substr($cache, 10)); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Write an item to the cache for a given number of minutes. |
|