|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of the Phalcon Framework. |
| 5 | + * |
| 6 | + * (c) Phalcon Team <team@phalcon.io> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE.txt |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Phalcon; |
| 13 | + |
| 14 | +use Phalcon\Cache\Adapter\AdapterInterface; |
| 15 | +use Psr\SimpleCache\CacheInterface; |
| 16 | + |
| 17 | +/** |
| 18 | + * This component offers caching capabilities for your application. |
| 19 | + * Phalcon\Cache implements PSR-16. |
| 20 | + */ |
| 21 | +class Cache implements CacheInterface |
| 22 | +{ |
| 23 | + /** |
| 24 | + * The adapter |
| 25 | + * |
| 26 | + * @var AdapterInterface |
| 27 | + */ |
| 28 | + protected $adapter; |
| 29 | + |
| 30 | + |
| 31 | + /** |
| 32 | + * The adapter |
| 33 | + * |
| 34 | + * @return AdapterInterface |
| 35 | + */ |
| 36 | + public function getAdapter() |
| 37 | + { |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Constructor. |
| 42 | + * |
| 43 | + * @param AdapterInterface $adapter The cache adapter |
| 44 | + */ |
| 45 | + public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $adapter) |
| 46 | + { |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Wipes clean the entire cache's keys. |
| 51 | + * |
| 52 | + * @return bool |
| 53 | + */ |
| 54 | + public function clear(): bool |
| 55 | + { |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Delete an item from the cache by its unique key. |
| 60 | + * |
| 61 | + * @param string $key The unique cache key of the item to delete. |
| 62 | + * |
| 63 | + * @return bool True if the item was successfully removed. False if there was an error. |
| 64 | + * |
| 65 | + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. |
| 66 | + * @param mixed $key |
| 67 | + * @return bool |
| 68 | + */ |
| 69 | + public function delete($key): bool |
| 70 | + { |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Deletes multiple cache items in a single operation. |
| 75 | + * |
| 76 | + * @param iterable $keys A list of string-based keys to be deleted. |
| 77 | + * |
| 78 | + * @return bool True if the items were successfully removed. False if there was an error. |
| 79 | + * |
| 80 | + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. |
| 81 | + * @param mixed $keys |
| 82 | + * @return bool |
| 83 | + */ |
| 84 | + public function deleteMultiple($keys): bool |
| 85 | + { |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Fetches a value from the cache. |
| 90 | + * |
| 91 | + * @param mixed $default Default value to return if the key does not exist. |
| 92 | + * |
| 93 | + * @return mixed The value of the item from the cache, or $default in case of cache miss. |
| 94 | + * |
| 95 | + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. |
| 96 | + * @param string $key The unique key of this item in the cache. |
| 97 | + * @param mixed $defaultValue |
| 98 | + * @return mixed |
| 99 | + */ |
| 100 | + public function get($key, $defaultValue = null) |
| 101 | + { |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Obtains multiple cache items by their unique keys. |
| 106 | + * |
| 107 | + * @param mixed $default Default value to return for keys that do not exist. |
| 108 | + * |
| 109 | + * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. |
| 110 | + * |
| 111 | + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. |
| 112 | + * @param iterable $keys A list of keys that can obtained in a single operation. |
| 113 | + * @param mixed $defaultValue |
| 114 | + * @return mixed |
| 115 | + */ |
| 116 | + public function getMultiple($keys, $defaultValue = null) |
| 117 | + { |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * Determines whether an item is present in the cache. |
| 122 | + * |
| 123 | + * @param string $key The cache item key. |
| 124 | + * |
| 125 | + * @return bool |
| 126 | + * |
| 127 | + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. |
| 128 | + * @param mixed $key |
| 129 | + * @return bool |
| 130 | + */ |
| 131 | + public function has($key): bool |
| 132 | + { |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
| 137 | + * |
| 138 | + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
| 139 | + * the driver supports TTL then the library may set a default value |
| 140 | + * for it or let the driver take care of that. |
| 141 | + * |
| 142 | + * @return bool True on success and false on failure. |
| 143 | + * |
| 144 | + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. |
| 145 | + * @param string $key The key of the item to store. |
| 146 | + * @param mixed $value The value of the item to store. Must be serializable. |
| 147 | + * @param mixed $ttl |
| 148 | + * @return bool |
| 149 | + */ |
| 150 | + public function set($key, $value, $ttl = null): bool |
| 151 | + { |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Persists a set of key => value pairs in the cache, with an optional TTL. |
| 156 | + * |
| 157 | + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
| 158 | + * the driver supports TTL then the library may set a default value |
| 159 | + * for it or let the driver take care of that. |
| 160 | + * |
| 161 | + * @return bool True on success and false on failure. |
| 162 | + * |
| 163 | + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value. |
| 164 | + * @param iterable $values A list of key => value pairs for a multiple-set operation. |
| 165 | + * @param mixed $ttl |
| 166 | + * @return bool |
| 167 | + */ |
| 168 | + public function setMultiple($values, $ttl = null): bool |
| 169 | + { |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * Checks the key. If it contains invalid characters an exception is thrown |
| 174 | + * |
| 175 | + * @param mixed $key |
| 176 | + */ |
| 177 | + protected function checkKey($key) |
| 178 | + { |
| 179 | + } |
| 180 | + |
| 181 | + /** |
| 182 | + * Checks the key. If it contains invalid characters an exception is thrown |
| 183 | + * |
| 184 | + * @param mixed $keys |
| 185 | + */ |
| 186 | + protected function checkKeys($keys) |
| 187 | + { |
| 188 | + } |
| 189 | +} |
0 commit comments