| 1 | <?php |
||
| 7 | abstract class ResultCache |
||
| 8 | { |
||
| 9 | /** @var int */ |
||
| 10 | protected $minutes = 1440; |
||
| 11 | |||
| 12 | /** @var CacheRepository */ |
||
| 13 | protected $cache; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Return / defines a unique cache key across the application. |
||
| 17 | * |
||
| 18 | * @return string |
||
| 19 | */ |
||
| 20 | abstract public function key(); |
||
| 21 | |||
| 22 | /** |
||
| 23 | * This methods must is responsible for returning the data |
||
| 24 | * that will be saved in cache. |
||
| 25 | * |
||
| 26 | * @return mixed |
||
| 27 | */ |
||
| 28 | abstract public function data(); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Return concrete used cache key. |
||
| 32 | * |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | 4 | protected function getCacheKey() |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Return object from the cache. |
||
| 42 | * |
||
| 43 | * @return mixed |
||
| 44 | */ |
||
| 45 | 7 | public function get() |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Removes cache. |
||
| 58 | * |
||
| 59 | * @return void |
||
| 60 | */ |
||
| 61 | 1 | public function forget() |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Set cache repository. |
||
| 68 | * |
||
| 69 | * @param CacheRepository $cache |
||
| 70 | * |
||
| 71 | * @return $this |
||
| 72 | */ |
||
| 73 | 1 | public function setCache(CacheRepository $cache) |
|
| 79 | |||
| 80 | /** |
||
| 81 | * Return cache implementation. |
||
| 82 | * |
||
| 83 | * @return CacheRepository |
||
| 84 | */ |
||
| 85 | 8 | public function getCache() |
|
| 89 | } |
||
| 90 |