1 | <?php |
||
20 | class Laravel5 |
||
21 | extends \Aimeos\MW\Cache\Base |
||
22 | implements \Aimeos\MW\Cache\Iface |
||
23 | { |
||
24 | private $object; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * Initializes the object instance. |
||
29 | * |
||
30 | * @param \Illuminate\Contracts\Cache\Store $cache Laravel cache object |
||
31 | */ |
||
32 | public function __construct( \Illuminate\Contracts\Cache\Store $cache ) |
||
36 | |||
37 | |||
38 | /** |
||
39 | * Removes all entries for the current site from the cache. |
||
40 | * |
||
41 | * @inheritDoc |
||
42 | */ |
||
43 | public function clear() |
||
44 | { |
||
45 | $this->object->flush(); |
||
46 | } |
||
47 | |||
48 | |||
49 | /** |
||
50 | * Removes the cache entry identified by the given key. |
||
51 | * |
||
52 | * @inheritDoc |
||
53 | * |
||
54 | * @param string $key Key string that identifies the single cache entry |
||
55 | */ |
||
56 | public function delete( $key ) |
||
57 | { |
||
58 | $this->object->forget( $key ); |
||
59 | } |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Removes the cache entries identified by the given keys. |
||
64 | * |
||
65 | * @inheritDoc |
||
66 | * |
||
67 | * @param string[] $keys List of key strings that identify the cache entries |
||
68 | * that should be removed |
||
69 | */ |
||
70 | public function deleteMultiple( $keys ) |
||
71 | { |
||
72 | foreach( $keys as $key ) { |
||
73 | $this->object->forget( $key ); |
||
74 | } |
||
75 | } |
||
76 | |||
77 | |||
78 | /** |
||
79 | * Removes the cache entries identified by the given tags. |
||
80 | * |
||
81 | * @inheritDoc |
||
82 | * |
||
83 | * @param string[] $tags List of tag strings that are associated to one or more |
||
84 | * cache entries that should be removed |
||
85 | */ |
||
86 | public function deleteByTags( array $tags ) |
||
87 | { |
||
88 | // $this->object->tags( $tag )->flush(); |
||
89 | $this->object->flush(); |
||
90 | } |
||
91 | |||
92 | |||
93 | /** |
||
94 | * Returns the value of the requested cache key. |
||
95 | * |
||
96 | * @inheritDoc |
||
97 | * |
||
98 | * @param string $name Path to the requested value like tree/node/classname |
||
99 | * @param string $default Value returned if requested key isn't found |
||
100 | * @return mixed Value associated to the requested key |
||
101 | */ |
||
102 | public function get( $name, $default = null ) |
||
110 | |||
111 | |||
112 | /** |
||
113 | * Returns the cached values for the given cache keys. |
||
114 | * |
||
115 | * @inheritDoc |
||
116 | * |
||
117 | * @param iterable $keys List of key strings for the requested cache entries |
||
118 | * @param mixed $default Default value to return for keys that do not exist |
||
119 | * @return array Associative list of key/value pairs for the requested cache |
||
120 | * entries. If a cache entry doesn't exist, neither its key nor a value |
||
121 | * will be in the result list |
||
122 | */ |
||
123 | public function getMultiple( $keys, $default = null ) |
||
138 | |||
139 | |||
140 | /** |
||
141 | * Returns the cached keys and values associated to the given tags. |
||
142 | * |
||
143 | * @inheritDoc |
||
144 | * |
||
145 | * @param string[] $tags List of tag strings associated to the requested cache entries |
||
146 | * @return array Associative list of key/value pairs for the requested cache |
||
147 | * entries. If a tag isn't associated to any cache entry, nothing is returned |
||
148 | * for that tag |
||
149 | */ |
||
150 | public function getMultipleByTags( array $tags ) |
||
154 | |||
155 | |||
156 | /** |
||
157 | * Sets the value for the given key in the cache. |
||
158 | * |
||
159 | * @inheritDoc |
||
160 | * |
||
161 | * @param string $key Key string for the given value like product/id/123 |
||
162 | * @param mixed $value Value string that should be stored for the given key |
||
163 | * @param int|string|null $expires Date/time string in "YYYY-MM-DD HH:mm:ss" |
||
164 | * format or as TTL value when the cache entry expires |
||
165 | * @param array $tags List of tag strings that should be assoicated to the |
||
166 | * given value in the cache |
||
167 | */ |
||
168 | public function set( $key, $value, $expires = null, array $tags = array() ) |
||
176 | |||
177 | |||
178 | /** |
||
179 | * Adds or overwrites the given key/value pairs in the cache, which is much |
||
180 | * more efficient than setting them one by one using the set() method. |
||
181 | * |
||
182 | * @inheritDoc |
||
183 | * |
||
184 | * @param iterable $pairs Associative list of key/value pairs. Both must be |
||
185 | * a string |
||
186 | * @param int|string|array $expires Associative list of keys and datetime |
||
187 | * string or integer TTL pairs. |
||
188 | * @param array $tags Associative list of key/tag or key/tags pairs that |
||
189 | * should be associated to the values identified by their key. The value |
||
190 | * associated to the key can either be a tag string or an array of tag strings |
||
191 | */ |
||
192 | public function setMultiple( $pairs, $expires = null, array $tags = array() ) |
||
202 | } |
||
203 |