1 | <?php namespace Valeryq\Cacheable\Traits; |
||
10 | trait CacheableTrait |
||
11 | { |
||
12 | /** |
||
13 | * Force by default is false |
||
14 | * |
||
15 | * @var bool |
||
16 | */ |
||
17 | private $force = false; |
||
18 | |||
19 | /** |
||
20 | * @var Repository |
||
21 | */ |
||
22 | private $repository; |
||
23 | |||
24 | /** |
||
25 | * Check if force is on or off |
||
26 | * |
||
27 | * @return boolean |
||
28 | */ |
||
29 | public function isForce() |
||
33 | |||
34 | /** |
||
35 | * Set flag as get a data. If with force it will without cached |
||
36 | * |
||
37 | * @param boolean $force |
||
38 | * |
||
39 | * @return $this |
||
40 | */ |
||
41 | public function setForce($force) |
||
47 | |||
48 | /** |
||
49 | * Set cache repository |
||
50 | * |
||
51 | * @param Repository $repository |
||
52 | */ |
||
53 | public function setRepository(Repository $repository) |
||
57 | |||
58 | /** |
||
59 | * Get cache repository |
||
60 | * |
||
61 | * @return Repository |
||
62 | */ |
||
63 | public function cache() |
||
71 | |||
72 | /** |
||
73 | * Get an item from the cache, or store the default value. |
||
74 | * |
||
75 | * @param string $key |
||
76 | * @param \DateTime|int $minutes |
||
77 | * @param \Closure $callback |
||
78 | * |
||
79 | * @return mixed |
||
80 | */ |
||
81 | public function remember($key, $minutes, Closure $callback) |
||
89 | |||
90 | /** |
||
91 | * Get an item from the cache, or store the default value forever. |
||
92 | * |
||
93 | * @param string $key |
||
94 | * @param \Closure $callback |
||
95 | * |
||
96 | * @return mixed |
||
97 | */ |
||
98 | public function rememberForever($key, Closure $callback) |
||
106 | } |
||
107 |