1 | <?php |
||
12 | class CacheableService |
||
13 | { |
||
14 | /** |
||
15 | * Cache manager object. |
||
16 | * |
||
17 | * @var \Illuminate\Cache\TaggableStore |
||
18 | */ |
||
19 | protected $cache; |
||
20 | |||
21 | /** |
||
22 | * Cacheable configurations. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $configurations; |
||
27 | |||
28 | /** |
||
29 | * Runtime cache. |
||
30 | * |
||
31 | * @var \Illuminate\Cache\ArrayStore |
||
32 | */ |
||
33 | protected $runtimeCache; |
||
34 | |||
35 | /** |
||
36 | * Class constructor. |
||
37 | * |
||
38 | * @param \Illuminate\Cache\CacheManager $cache |
||
39 | * @param \Illuminate\Cache\ArrayStore $runtimeCache |
||
40 | */ |
||
41 | public function __construct(CacheManager $cache, ArrayStore $runtimeCache) |
||
47 | |||
48 | /** |
||
49 | * Just an alias of wrap() method. |
||
50 | * |
||
51 | * @param mixed $repository |
||
52 | * |
||
53 | * @return \Suitmedia\Cacheable\CacheableDecorator |
||
54 | */ |
||
55 | public function build($repository) |
||
59 | |||
60 | /** |
||
61 | * Flush cache. |
||
62 | * |
||
63 | * @param mixed $tags |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | public function flush($tags = null) |
||
72 | |||
73 | /** |
||
74 | * Get configuration value. |
||
75 | * |
||
76 | * @param string $key |
||
77 | * |
||
78 | * @return mixed |
||
79 | */ |
||
80 | public function getConfiguration($key) |
||
84 | |||
85 | /** |
||
86 | * Get runtime cached object. |
||
87 | * |
||
88 | * @param mixed $tags |
||
89 | * @param string $key |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | protected function getRuntimeCache($tags, $key) |
||
97 | |||
98 | /** |
||
99 | * Retrieve cached items. |
||
100 | * |
||
101 | * @param mixed $tags |
||
102 | * @param string $key |
||
103 | * @param int $duration |
||
104 | * @param Closure $callable |
||
105 | * |
||
106 | * @return mixed |
||
107 | */ |
||
108 | public function retrieve($tags, $key, $duration, Closure $callable) |
||
124 | |||
125 | /** |
||
126 | * Set runtime cache object. |
||
127 | * |
||
128 | * @param mixed $tags |
||
129 | * @param string $key |
||
130 | * @param mixed $value |
||
131 | * |
||
132 | * @return void |
||
133 | */ |
||
134 | protected function setRuntimeCache($tags, $key, $value) |
||
138 | |||
139 | /** |
||
140 | * Get tagged cache object. |
||
141 | * |
||
142 | * @param TaggableStore $cache |
||
143 | * @param mixed $tags |
||
144 | * |
||
145 | * @return \Illuminate\Cache\TaggedCache|TaggableStore |
||
146 | */ |
||
147 | protected function taggedCache(TaggableStore $cache, $tags) |
||
151 | |||
152 | /** |
||
153 | * Build CacheableDecorator and wrap the given class name |
||
154 | * or repository object. |
||
155 | * |
||
156 | * @param mixed $repository |
||
157 | * |
||
158 | * @return \Suitmedia\Cacheable\CacheableDecorator |
||
159 | */ |
||
160 | public function wrap($repository) |
||
168 | |||
169 | /** |
||
170 | * Wrap the given CacheableRepository with a new CacheableDecorator. |
||
171 | * |
||
172 | * @param \Suitmedia\Cacheable\Contracts\CacheableRepository $repository |
||
173 | * |
||
174 | * @return \Suitmedia\Cacheable\CacheableDecorator |
||
175 | */ |
||
176 | protected function wrapWithDecorator(CacheableRepository $repository) |
||
180 | } |
||
181 |