| 1 | <?php |
||
| 5 | class MemoryCache implements CacheInterface |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @var array |
||
| 10 | */ |
||
| 11 | protected $records = []; |
||
| 12 | |||
| 13 | |||
| 14 | /** |
||
| 15 | * Retrieve the nodes under the given key. |
||
| 16 | * |
||
| 17 | * @param string $key |
||
| 18 | * |
||
| 19 | * @return string[] |
||
| 20 | */ |
||
| 21 | 4 | public function get($key) |
|
| 37 | |||
| 38 | |||
| 39 | /** |
||
| 40 | * Cache the given Nodes. |
||
| 41 | * |
||
| 42 | * @param string $key |
||
| 43 | * @param string[] $nodes |
||
| 44 | * @param int $ttl TTL in seconds. |
||
| 45 | * |
||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | 6 | public function set($key, array $nodes, $ttl) |
|
| 54 | |||
| 55 | |||
| 56 | /** |
||
| 57 | * Return seconds left until the key expires. |
||
| 58 | * |
||
| 59 | * @param string $key |
||
| 60 | * |
||
| 61 | * @return int The number of seconds the key is valid. 0 if expired or unknown. |
||
| 62 | */ |
||
| 63 | 2 | public function expires($key) |
|
| 71 | } |