fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / Cache / Storage / Adapter / AbstractZendServer.php
blob5caeb9675d97f04b9e23aff9001aa9869533f984
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-2015 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\Exception;
14 use Zend\Cache\Storage\Capabilities;
16 abstract class AbstractZendServer extends AbstractAdapter
18 /**
19 * The namespace separator used on Zend Data Cache functions
21 * @var string
23 const NAMESPACE_SEPARATOR = '::';
25 /* reading */
27 /**
28 * Internal method to get an item.
30 * @param string $normalizedKey
31 * @param bool $success
32 * @param mixed $casToken
33 * @return mixed Data on success, null on failure
34 * @throws Exception\ExceptionInterface
36 protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
38 $namespace = $this->getOptions()->getNamespace();
39 $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
41 $result = $this->zdcFetch($prefix . $normalizedKey);
42 if ($result === null) {
43 $success = false;
44 } else {
45 $success = true;
46 $casToken = $result;
49 return $result;
52 /**
53 * Internal method to get multiple items.
55 * @param array $normalizedKeys
56 * @return array Associative array of keys and values
57 * @throws Exception\ExceptionInterface
59 protected function internalGetItems(array & $normalizedKeys)
61 $namespace = $this->getOptions()->getNamespace();
62 if ($namespace === '') {
63 return $this->zdcFetchMulti($normalizedKeys);
66 $prefix = $namespace . self::NAMESPACE_SEPARATOR;
67 $internalKeys = array();
68 foreach ($normalizedKeys as $normalizedKey) {
69 $internalKeys[] = $prefix . $normalizedKey;
72 $fetch = $this->zdcFetchMulti($internalKeys);
73 $result = array();
74 $prefixL = strlen($prefix);
75 foreach ($fetch as $k => & $v) {
76 $result[substr($k, $prefixL)] = $v;
79 return $result;
82 /**
83 * Internal method to test if an item exists.
85 * @param string $normalizedKey
86 * @return bool
87 * @throws Exception\ExceptionInterface
89 protected function internalHasItem(& $normalizedKey)
91 $namespace = $this->getOptions()->getNamespace();
92 $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
93 return ($this->zdcFetch($prefix . $normalizedKey) !== false);
96 /**
97 * Internal method to test multiple items.
99 * @param array $normalizedKeys
100 * @return array Array of found keys
101 * @throws Exception\ExceptionInterface
103 protected function internalHasItems(array & $normalizedKeys)
105 $namespace = $this->getOptions()->getNamespace();
106 if ($namespace === '') {
107 return array_keys($this->zdcFetchMulti($normalizedKeys));
110 $prefix = $namespace . self::NAMESPACE_SEPARATOR;
111 $internalKeys = array();
112 foreach ($normalizedKeys as $normalizedKey) {
113 $internalKeys[] = $prefix . $normalizedKey;
116 $fetch = $this->zdcFetchMulti($internalKeys);
117 $result = array();
118 $prefixL = strlen($prefix);
119 foreach ($fetch as $internalKey => & $value) {
120 $result[] = substr($internalKey, $prefixL);
123 return $result;
127 * Get metadata for multiple items
129 * @param array $normalizedKeys
130 * @return array Associative array of keys and metadata
132 * @triggers getMetadatas.pre(PreEvent)
133 * @triggers getMetadatas.post(PostEvent)
134 * @triggers getMetadatas.exception(ExceptionEvent)
136 protected function internalGetMetadatas(array & $normalizedKeys)
138 $namespace = $this->getOptions()->getNamespace();
139 if ($namespace === '') {
140 $result = $this->zdcFetchMulti($normalizedKeys);
141 return array_fill_keys(array_keys($result), array());
144 $prefix = $namespace . self::NAMESPACE_SEPARATOR;
145 $internalKeys = array();
146 foreach ($normalizedKeys as $normalizedKey) {
147 $internalKeys[] = $prefix . $normalizedKey;
150 $fetch = $this->zdcFetchMulti($internalKeys);
151 $result = array();
152 $prefixL = strlen($prefix);
153 foreach ($fetch as $internalKey => $value) {
154 $result[substr($internalKey, $prefixL)] = array();
157 return $result;
160 /* writing */
163 * Internal method to store an item.
165 * @param string $normalizedKey
166 * @param mixed $value
167 * @return bool
168 * @throws Exception\ExceptionInterface
170 protected function internalSetItem(& $normalizedKey, & $value)
172 $options = $this->getOptions();
173 $namespace = $options->getNamespace();
174 $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
175 $this->zdcStore($prefix . $normalizedKey, $value, $options->getTtl());
176 return true;
180 * Internal method to remove an item.
182 * @param string $normalizedKey
183 * @return bool
184 * @throws Exception\ExceptionInterface
186 protected function internalRemoveItem(& $normalizedKey)
188 $namespace = $this->getOptions()->getNamespace();
189 $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
190 return $this->zdcDelete($prefix . $normalizedKey);
193 /* status */
196 * Internal method to get capabilities of this adapter
198 * @return Capabilities
200 protected function internalGetCapabilities()
202 if ($this->capabilities === null) {
203 $this->capabilityMarker = new stdClass();
204 $this->capabilities = new Capabilities(
205 $this,
206 $this->capabilityMarker,
207 array(
208 'supportedDatatypes' => array(
209 'NULL' => true,
210 'boolean' => true,
211 'integer' => true,
212 'double' => true,
213 'string' => true,
214 'array' => true,
215 'object' => 'object',
216 'resource' => false,
218 'supportedMetadata' => array(),
219 'maxTtl' => 0,
220 'staticTtl' => true,
221 'ttlPrecision' => 1,
222 'useRequestTime' => false,
223 'expiredRead' => false,
224 'maxKeyLength' => 0,
225 'namespaceIsPrefix' => true,
226 'namespaceSeparator' => self::NAMESPACE_SEPARATOR,
231 return $this->capabilities;
234 /* internal wrapper of zend_[disk|shm]_cache_* functions */
237 * Store data into Zend Data Cache (zdc)
239 * @param string $internalKey
240 * @param mixed $value
241 * @param int $ttl
242 * @return void
243 * @throws Exception\RuntimeException
245 abstract protected function zdcStore($internalKey, $value, $ttl);
248 * Fetch a single item from Zend Data Cache (zdc)
250 * @param string $internalKey
251 * @return mixed The stored value or FALSE if item wasn't found
252 * @throws Exception\RuntimeException
254 abstract protected function zdcFetch($internalKey);
257 * Fetch multiple items from Zend Data Cache (zdc)
259 * @param array $internalKeys
260 * @return array All found items
261 * @throws Exception\RuntimeException
263 abstract protected function zdcFetchMulti(array $internalKeys);
266 * Delete data from Zend Data Cache (zdc)
268 * @param string $internalKey
269 * @return bool
270 * @throws Exception\RuntimeException
272 abstract protected function zdcDelete($internalKey);