| 1 | <?php |
||
| 22 | trait Caches |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var Cache |
||
| 26 | */ |
||
| 27 | protected $cache; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Sets cache store. |
||
| 31 | * |
||
| 32 | * @param Cache $cache |
||
| 33 | * |
||
| 34 | * @return $this |
||
| 35 | */ |
||
| 36 | public function setCache(Cache $cache) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Gets cache store. Defaults to file system in system temp folder. |
||
| 45 | * |
||
| 46 | * @return Cache |
||
| 47 | */ |
||
| 48 | public function getCache() |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Gets the cached data. |
||
| 55 | * |
||
| 56 | * @param string $key |
||
| 57 | * @param mixed $default A default value or a callable to return the value. |
||
| 58 | * |
||
| 59 | * @return mixed |
||
| 60 | */ |
||
| 61 | public function get($key, $default = null) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Sets the cached data. |
||
| 76 | * |
||
| 77 | * @param string $key |
||
| 78 | * @param mixed $value |
||
| 79 | * @param int $life Cache life time in seconds. |
||
| 80 | * |
||
| 81 | * @return bool |
||
| 82 | */ |
||
| 83 | public function set($key, $value, $life = 0) |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Removes the cached data. |
||
| 90 | * |
||
| 91 | * @param string $key |
||
| 92 | * |
||
| 93 | * @return bool |
||
| 94 | */ |
||
| 95 | public function remove($key) |
||
| 99 | |||
| 100 | } |