3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Cache\Storage
;
14 interface StorageInterface
19 * @param array|Traversable|Adapter\AdapterOptions $options
20 * @return StorageInterface Fluent interface
22 public function setOptions($options);
27 * @return Adapter\AdapterOptions
29 public function getOptions();
37 * @param bool $success
38 * @param mixed $casToken
39 * @return mixed Data on success, null on failure
40 * @throws \Zend\Cache\Exception\ExceptionInterface
42 public function getItem($key, & $success = null, & $casToken = null);
48 * @return array Associative array of keys and values
49 * @throws \Zend\Cache\Exception\ExceptionInterface
51 public function getItems(array $keys);
54 * Test if an item exists.
58 * @throws \Zend\Cache\Exception\ExceptionInterface
60 public function hasItem($key);
63 * Test multiple items.
66 * @return array Array of found keys
67 * @throws \Zend\Cache\Exception\ExceptionInterface
69 public function hasItems(array $keys);
72 * Get metadata of an item.
75 * @return array|bool Metadata on success, false on failure
76 * @throws \Zend\Cache\Exception\ExceptionInterface
78 public function getMetadata($key);
81 * Get multiple metadata
84 * @return array Associative array of keys and metadata
85 * @throws \Zend\Cache\Exception\ExceptionInterface
87 public function getMetadatas(array $keys);
97 * @throws \Zend\Cache\Exception\ExceptionInterface
99 public function setItem($key, $value);
102 * Store multiple items.
104 * @param array $keyValuePairs
105 * @return array Array of not stored keys
106 * @throws \Zend\Cache\Exception\ExceptionInterface
108 public function setItems(array $keyValuePairs);
114 * @param mixed $value
116 * @throws \Zend\Cache\Exception\ExceptionInterface
118 public function addItem($key, $value);
121 * Add multiple items.
123 * @param array $keyValuePairs
124 * @return array Array of not stored keys
125 * @throws \Zend\Cache\Exception\ExceptionInterface
127 public function addItems(array $keyValuePairs);
130 * Replace an existing item.
133 * @param mixed $value
135 * @throws \Zend\Cache\Exception\ExceptionInterface
137 public function replaceItem($key, $value);
140 * Replace multiple existing items.
142 * @param array $keyValuePairs
143 * @return array Array of not stored keys
144 * @throws \Zend\Cache\Exception\ExceptionInterface
146 public function replaceItems(array $keyValuePairs);
149 * Set an item only if token matches
151 * It uses the token received from getItem() to check if the item has
152 * changed before overwriting it.
154 * @param mixed $token
156 * @param mixed $value
158 * @throws \Zend\Cache\Exception\ExceptionInterface
162 public function checkAndSetItem($token, $key, $value);
165 * Reset lifetime of an item
169 * @throws \Zend\Cache\Exception\ExceptionInterface
171 public function touchItem($key);
174 * Reset lifetime of multiple items.
177 * @return array Array of not updated keys
178 * @throws \Zend\Cache\Exception\ExceptionInterface
180 public function touchItems(array $keys);
187 * @throws \Zend\Cache\Exception\ExceptionInterface
189 public function removeItem($key);
192 * Remove multiple items.
195 * @return array Array of not removed keys
196 * @throws \Zend\Cache\Exception\ExceptionInterface
198 public function removeItems(array $keys);
205 * @return int|bool The new value on success, false on failure
206 * @throws \Zend\Cache\Exception\ExceptionInterface
208 public function incrementItem($key, $value);
211 * Increment multiple items.
213 * @param array $keyValuePairs
214 * @return array Associative array of keys and new values
215 * @throws \Zend\Cache\Exception\ExceptionInterface
217 public function incrementItems(array $keyValuePairs);
224 * @return int|bool The new value on success, false on failure
225 * @throws \Zend\Cache\Exception\ExceptionInterface
227 public function decrementItem($key, $value);
230 * Decrement multiple items.
232 * @param array $keyValuePairs
233 * @return array Associative array of keys and new values
234 * @throws \Zend\Cache\Exception\ExceptionInterface
236 public function decrementItems(array $keyValuePairs);
241 * Capabilities of this storage
243 * @return Capabilities
245 public function getCapabilities();