composer package updates
[openemr.git] / vendor / zendframework / zend-cache / src / Storage / Adapter / BlackHole.php
blob9ef76e194f1f54c4cb6f7a5d359431d7c76f03e7
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Cache\Storage\Adapter;
12 use stdClass;
13 use Zend\Cache\Storage\AvailableSpaceCapableInterface;
14 use Zend\Cache\Storage\Capabilities;
15 use Zend\Cache\Storage\ClearByNamespaceInterface;
16 use Zend\Cache\Storage\ClearByPrefixInterface;
17 use Zend\Cache\Storage\ClearExpiredInterface;
18 use Zend\Cache\Storage\FlushableInterface;
19 use Zend\Cache\Storage\IterableInterface;
20 use Zend\Cache\Storage\OptimizableInterface;
21 use Zend\Cache\Storage\StorageInterface;
22 use Zend\Cache\Storage\TaggableInterface;
23 use Zend\Cache\Storage\TotalSpaceCapableInterface;
25 class BlackHole implements
26 StorageInterface,
27 AvailableSpaceCapableInterface,
28 ClearByNamespaceInterface,
29 ClearByPrefixInterface,
30 ClearExpiredInterface,
31 FlushableInterface,
32 IterableInterface,
33 OptimizableInterface,
34 TaggableInterface,
35 TotalSpaceCapableInterface
37 /**
38 * Capabilities of this adapter
40 * @var null|Capabilities
42 protected $capabilities = null;
44 /**
45 * Marker to change capabilities
47 * @var null|object
49 protected $capabilityMarker;
51 /**
52 * options
54 * @var null|AdapterOptions
56 protected $options;
58 /**
59 * Constructor
61 * @param null|array|\Traversable|AdapterOptions $options
63 public function __construct($options = null)
65 if ($options) {
66 $this->setOptions($options);
70 /**
71 * Set options.
73 * @param array|\Traversable|AdapterOptions $options
74 * @return BlackHole Provides a fluent interface
76 public function setOptions($options)
78 if ($this->options !== $options) {
79 if (! $options instanceof AdapterOptions) {
80 $options = new AdapterOptions($options);
83 if ($this->options) {
84 $this->options->setAdapter(null);
86 $options->setAdapter($this);
87 $this->options = $options;
89 return $this;
92 /**
93 * Get options
95 * @return AdapterOptions
97 public function getOptions()
99 if (! $this->options) {
100 $this->setOptions(new AdapterOptions());
102 return $this->options;
106 * Get an item.
108 * @param string $key
109 * @param bool $success
110 * @param mixed $casToken
111 * @return mixed Data on success, null on failure
113 public function getItem($key, & $success = null, & $casToken = null)
115 $success = false;
116 return;
120 * Get multiple items.
122 * @param array $keys
123 * @return array Associative array of keys and values
125 public function getItems(array $keys)
127 return [];
131 * Test if an item exists.
133 * @param string $key
134 * @return bool
136 public function hasItem($key)
138 return false;
142 * Test multiple items.
144 * @param array $keys
145 * @return array Array of found keys
147 public function hasItems(array $keys)
149 return [];
153 * Get metadata of an item.
155 * @param string $key
156 * @return array|bool Metadata on success, false on failure
158 public function getMetadata($key)
160 return false;
164 * Get multiple metadata
166 * @param array $keys
167 * @return array Associative array of keys and metadata
169 public function getMetadatas(array $keys)
171 return [];
175 * Store an item.
177 * @param string $key
178 * @param mixed $value
179 * @return bool
181 public function setItem($key, $value)
183 return false;
187 * Store multiple items.
189 * @param array $keyValuePairs
190 * @return array Array of not stored keys
192 public function setItems(array $keyValuePairs)
194 return array_keys($keyValuePairs);
198 * Add an item.
200 * @param string $key
201 * @param mixed $value
202 * @return bool
204 public function addItem($key, $value)
206 return false;
210 * Add multiple items.
212 * @param array $keyValuePairs
213 * @return array Array of not stored keys
215 public function addItems(array $keyValuePairs)
217 return array_keys($keyValuePairs);
221 * Replace an existing item.
223 * @param string $key
224 * @param mixed $value
225 * @return bool
227 public function replaceItem($key, $value)
229 return false;
233 * Replace multiple existing items.
235 * @param array $keyValuePairs
236 * @return array Array of not stored keys
238 public function replaceItems(array $keyValuePairs)
240 return array_keys($keyValuePairs);
244 * Set an item only if token matches
246 * It uses the token received from getItem() to check if the item has
247 * changed before overwriting it.
249 * @param mixed $token
250 * @param string $key
251 * @param mixed $value
252 * @return bool
254 public function checkAndSetItem($token, $key, $value)
256 return false;
260 * Reset lifetime of an item
262 * @param string $key
263 * @return bool
265 public function touchItem($key)
267 return false;
271 * Reset lifetime of multiple items.
273 * @param array $keys
274 * @return array Array of not updated keys
276 public function touchItems(array $keys)
278 return $keys;
282 * Remove an item.
284 * @param string $key
285 * @return bool
287 public function removeItem($key)
289 return false;
293 * Remove multiple items.
295 * @param array $keys
296 * @return array Array of not removed keys
298 public function removeItems(array $keys)
300 return $keys;
304 * Increment an item.
306 * @param string $key
307 * @param int $value
308 * @return int|bool The new value on success, false on failure
310 public function incrementItem($key, $value)
312 return false;
316 * Increment multiple items.
318 * @param array $keyValuePairs
319 * @return array Associative array of keys and new values
321 public function incrementItems(array $keyValuePairs)
323 return [];
327 * Decrement an item.
329 * @param string $key
330 * @param int $value
331 * @return int|bool The new value on success, false on failure
333 public function decrementItem($key, $value)
335 return false;
339 * Decrement multiple items.
341 * @param array $keyValuePairs
342 * @return array Associative array of keys and new values
344 public function decrementItems(array $keyValuePairs)
346 return [];
350 * Capabilities of this storage
352 * @return Capabilities
354 public function getCapabilities()
356 if ($this->capabilities === null) {
357 // use default capabilities only
358 $this->capabilityMarker = new stdClass();
359 $this->capabilities = new Capabilities($this, $this->capabilityMarker);
361 return $this->capabilities;
364 /* AvailableSpaceCapableInterface */
367 * Get available space in bytes
369 * @return int|float
371 public function getAvailableSpace()
373 return 0;
376 /* ClearByNamespaceInterface */
379 * Remove items of given namespace
381 * @param string $namespace
382 * @return bool
384 public function clearByNamespace($namespace)
386 return false;
389 /* ClearByPrefixInterface */
392 * Remove items matching given prefix
394 * @param string $prefix
395 * @return bool
397 public function clearByPrefix($prefix)
399 return false;
402 /* ClearExpiredInterface */
405 * Remove expired items
407 * @return bool
409 public function clearExpired()
411 return false;
414 /* FlushableInterface */
417 * Flush the whole storage
419 * @return bool
421 public function flush()
423 return false;
426 /* IterableInterface */
429 * Get the storage iterator
431 * @return KeyListIterator
433 public function getIterator()
435 return new KeyListIterator($this, []);
438 /* OptimizableInterface */
441 * Optimize the storage
443 * @return bool
445 public function optimize()
447 return false;
450 /* TaggableInterface */
453 * Set tags to an item by given key.
454 * An empty array will remove all tags.
456 * @param string $key
457 * @param string[] $tags
458 * @return bool
460 public function setTags($key, array $tags)
462 return false;
466 * Get tags of an item by given key
468 * @param string $key
469 * @return string[]|FALSE
471 public function getTags($key)
473 return false;
477 * Remove items matching given tags.
479 * If $disjunction only one of the given tags must match
480 * else all given tags must match.
482 * @param string[] $tags
483 * @param bool $disjunction
484 * @return bool
486 public function clearByTags(array $tags, $disjunction = false)
488 return false;
491 /* TotalSpaceCapableInterface */
494 * Get total space in bytes
496 * @return int|float
498 public function getTotalSpace()
500 return 0;