| 1 | <?php |
||
| 9 | class Cache implements CacheInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var CacheStorageInterface |
||
| 13 | */ |
||
| 14 | protected $cache; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Create new instance with $CacheStorage |
||
| 18 | * |
||
| 19 | * @param CacheStorageInterface $cacheStorage |
||
| 20 | * @return CacheInterface |
||
| 21 | */ |
||
| 22 | public function withCacheStorage(CacheStorageInterface $cacheStorage) |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Get Cache Storage |
||
| 31 | * |
||
| 32 | * @return CacheStorageInterface |
||
| 33 | */ |
||
| 34 | public function getCacheStorage() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Cache constructor. |
||
| 41 | * |
||
| 42 | * @param CacheStorageInterface|null $cacheStorage |
||
| 43 | */ |
||
| 44 | public function __construct(CacheStorageInterface $cacheStorage = null) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Check if cache key exists. |
||
| 55 | * |
||
| 56 | * @param $key |
||
| 57 | * @return bool |
||
| 58 | */ |
||
| 59 | public function has($key) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Save Cache Value. |
||
| 66 | * |
||
| 67 | * @param string $key |
||
| 68 | * @param mixed $value |
||
| 69 | * @param int $expires |
||
| 70 | * @return void |
||
| 71 | */ |
||
| 72 | public function set($key, $value, $expires) |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Get Cache Value from key. |
||
| 79 | * |
||
| 80 | * @param string $key |
||
| 81 | * @return mixed |
||
| 82 | */ |
||
| 83 | public function get($key = '') |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Delete Cache Key. |
||
| 90 | * |
||
| 91 | * @param $key |
||
| 92 | */ |
||
| 93 | public function delete($key) |
||
| 97 | } |
||
| 98 |