1 | <?php |
||
20 | class Flow |
||
|
|||
21 | extends \Aimeos\MW\Cache\Base |
||
22 | implements \Aimeos\MW\Cache\Iface |
||
23 | { |
||
24 | private $object; |
||
25 | private $prefix; |
||
26 | |||
27 | |||
28 | /** |
||
29 | * Initializes the object instance. |
||
30 | * |
||
31 | * @param array $config List of configuration values |
||
32 | * @param \TYPO3\Flow\Cache\Frontend\FrontendInterface $cache TYPO3 cache object |
||
33 | */ |
||
34 | public function __construct( array $config, \TYPO3\Flow\Cache\Frontend\FrontendInterface $cache ) |
||
35 | { |
||
36 | $this->prefix = ( isset( $config['siteid'] ) ? $config['siteid'] . '-' : '' ); |
||
37 | $this->object = $cache; |
||
38 | } |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Removes the cache entry identified by the given key. |
||
43 | * |
||
44 | * @inheritDoc |
||
45 | * |
||
46 | * @param string $key Key string that identifies the single cache entry |
||
47 | */ |
||
48 | public function delete( $key ) |
||
52 | |||
53 | |||
54 | /** |
||
55 | * Removes the cache entries identified by the given keys. |
||
56 | * |
||
57 | * @inheritDoc |
||
58 | * |
||
59 | * @param \Traversable|array $keys List of key strings that identify the cache entries |
||
60 | * that should be removed |
||
61 | */ |
||
62 | public function deleteMultiple( $keys ) |
||
63 | { |
||
64 | foreach( $keys as $key ) { |
||
65 | $this->object->remove( $this->prefix . $key ); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | |||
70 | /** |
||
71 | * Removes the cache entries identified by the given tags. |
||
72 | * |
||
73 | * @inheritDoc |
||
74 | * |
||
75 | * @param string[] $tags List of tag strings that are associated to one or more |
||
76 | * cache entries that should be removed |
||
77 | */ |
||
78 | public function deleteByTags( array $tags ) |
||
84 | |||
85 | |||
86 | /** |
||
87 | * Removes all entries for the current site from the cache. |
||
88 | * |
||
89 | * @inheritDoc |
||
90 | */ |
||
91 | public function clear() |
||
92 | { |
||
93 | if( $this->prefix ) { |
||
94 | $this->object->flushByTag( $this->prefix . 'siteid' ); |
||
95 | } else { |
||
96 | $this->object->flush(); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | |||
101 | /** |
||
102 | * Returns the value of the requested cache key. |
||
103 | * |
||
104 | * @inheritDoc |
||
105 | * |
||
106 | * @param string $name Path to the requested value like tree/node/classname |
||
107 | * @param string $default Value returned if requested key isn't found |
||
108 | * @return mixed Value associated to the requested key |
||
109 | */ |
||
110 | public function get( $name, $default = null ) |
||
118 | |||
119 | |||
120 | /** |
||
121 | * Returns the cached values for the given cache keys. |
||
122 | * |
||
123 | * @inheritDoc |
||
124 | * |
||
125 | * @param \Traversable|array $keys List of key strings for the requested cache entries |
||
126 | * @param mixed $default Default value to return for keys that do not exist |
||
127 | * @return array Associative list of key/value pairs for the requested cache |
||
128 | * entries. If a cache entry doesn't exist, neither its key nor a value |
||
129 | * will be in the result list |
||
130 | * @throws \Aimeos\MW\Cache\Exception If the cache server doesn't respond |
||
131 | */ |
||
132 | public function getMultiple( $keys, $default = null ) |
||
147 | |||
148 | |||
149 | /** |
||
150 | * Returns the cached keys and values associated to the given tags. |
||
151 | * |
||
152 | * @inheritDoc |
||
153 | * |
||
154 | * @param string[] $tags List of tag strings associated to the requested cache entries |
||
155 | * @return array Associative list of key/value pairs for the requested cache |
||
156 | * entries. If a tag isn't associated to any cache entry, nothing is returned |
||
157 | * for that tag |
||
158 | */ |
||
159 | public function getMultipleByTags( array $tags ) |
||
179 | |||
180 | |||
181 | /** |
||
182 | * Sets the value for the given key in the cache. |
||
183 | * |
||
184 | * @inheritDoc |
||
185 | * |
||
186 | * @param string $name Key string for the given value like product/id/123 |
||
187 | * @param mixed $value Value string that should be stored for the given key |
||
188 | * @param int|string|null $expires Date/time string in "YYYY-MM-DD HH:mm:ss" |
||
189 | * format when the cache entry expires |
||
190 | * @param array $tags List of tag strings that should be assoicated to the |
||
191 | * given value in the cache |
||
192 | */ |
||
193 | public function set( $key, $value, $expires = null, array $tags = array() ) |
||
207 | |||
208 | |||
209 | /** |
||
210 | * Adds or overwrites the given key/value pairs in the cache, which is much |
||
211 | * more efficient than setting them one by one using the set() method. |
||
212 | * |
||
213 | * @inheritDoc |
||
214 | * |
||
215 | * @param \Traversable|array $pairs Associative list of key/value pairs. Both must be |
||
216 | * a string |
||
217 | * @param array|int|string|null $expires Associative list of keys and datetime |
||
218 | * string or integer TTL pairs. |
||
219 | * @param array $tags Associative list of key/tag or key/tags pairs that |
||
220 | * should be associated to the values identified by their key. The value |
||
221 | * associated to the key can either be a tag string or an array of tag strings |
||
222 | * @return null |
||
223 | * @throws \Aimeos\MW\Cache\Exception If the cache server doesn't respond |
||
224 | */ |
||
225 | public function setMultiple( $pairs, $expires = null, array $tags = array() ) |
||
235 | } |
||
236 |