1 | <?php |
||
12 | class CacheableService |
||
13 | { |
||
14 | /** |
||
15 | * Cache manager object. |
||
16 | * |
||
17 | * @var \Illuminate\Cache\TaggableStore |
||
18 | */ |
||
19 | protected $cache; |
||
20 | |||
21 | /** |
||
22 | * Runtime cache. |
||
23 | * |
||
24 | * @var \Illuminate\Cache\ArrayStore |
||
25 | */ |
||
26 | protected $runtimeCache; |
||
27 | |||
28 | /** |
||
29 | * Class constructor. |
||
30 | * |
||
31 | * @param \Illuminate\Cache\CacheManager $cache |
||
32 | * @param \Illuminate\Cache\ArrayStore $runtimeCache |
||
33 | */ |
||
34 | public function __construct(CacheManager $cache, ArrayStore $runtimeCache) |
||
39 | |||
40 | /** |
||
41 | * Just an alias of wrap() method. |
||
42 | * |
||
43 | * @param mixed $repository |
||
44 | * |
||
45 | * @return \Suitmedia\Cacheable\CacheableDecorator |
||
46 | */ |
||
47 | public function build($repository) |
||
51 | |||
52 | /** |
||
53 | * Flush cache. |
||
54 | * |
||
55 | * @param mixed $tags |
||
56 | * |
||
57 | * @return void |
||
58 | */ |
||
59 | public function flush($tags = null) |
||
64 | |||
65 | /** |
||
66 | * Get runtime cached object. |
||
67 | * |
||
68 | * @param mixed $tags |
||
69 | * @param string $key |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | protected function getRuntimeCache($tags, $key) |
||
77 | |||
78 | /** |
||
79 | * Retrieve cached items. |
||
80 | * |
||
81 | * @param mixed $tags |
||
82 | * @param string $key |
||
83 | * @param int $duration |
||
84 | * @param Closure $callable |
||
85 | * |
||
86 | * @return mixed |
||
87 | */ |
||
88 | public function retrieve($tags, $key, $duration, Closure $callable) |
||
104 | |||
105 | /** |
||
106 | * Set runtime cache object. |
||
107 | * |
||
108 | * @param mixed $tags |
||
109 | * @param string $key |
||
110 | * @param mixed $value |
||
111 | * |
||
112 | * @return void |
||
113 | */ |
||
114 | protected function setRuntimeCache($tags, $key, $value) |
||
118 | |||
119 | /** |
||
120 | * Get tagged cache object. |
||
121 | * |
||
122 | * @param TaggableStore $cache |
||
123 | * @param mixed $tags |
||
124 | * |
||
125 | * @return \Illuminate\Cache\TaggedCache|TaggableStore |
||
126 | */ |
||
127 | protected function taggedCache(TaggableStore $cache, $tags) |
||
131 | |||
132 | /** |
||
133 | * Build CacheableDecorator and wrap the given class name |
||
134 | * or repository object. |
||
135 | * |
||
136 | * @param mixed $repository |
||
137 | * |
||
138 | * @return \Suitmedia\Cacheable\CacheableDecorator |
||
139 | */ |
||
140 | public function wrap($repository) |
||
148 | |||
149 | /** |
||
150 | * Wrap the given CacheableRepository with a new CacheableDecorator. |
||
151 | * |
||
152 | * @param \Suitmedia\Cacheable\Contracts\CacheableRepository $repository |
||
153 | * |
||
154 | * @return \Suitmedia\Cacheable\CacheableDecorator |
||
155 | */ |
||
156 | protected function wrapWithDecorator(CacheableRepository $repository) |
||
160 | } |
||
161 |