mixed $cacheValue). */ private $values = []; /** * CRM_Utils_Cache_FastArrayDecorator constructor. * @param \CRM_Utils_Cache_Interface $delegate * @param int $defaultTimeout * Default number of seconds each cache-item should endure. */ public function __construct(\CRM_Utils_Cache_Interface $delegate, $defaultTimeout = 3600) { $this->defaultTimeout = $defaultTimeout; $this->delegate = $delegate; } public function set($key, $value, $ttl = NULL) { if (is_int($ttl) && $ttl <= 0) { return $this->delete($key); } if ($this->delegate->set($key, $value, $ttl)) { $this->values[$key] = $value; return TRUE; } else { return FALSE; } } public function get($key, $default = NULL) { CRM_Utils_Cache::assertValidKey($key); if (array_key_exists($key, $this->values)) { return $this->values[$key]; } $nack = CRM_Utils_Cache::nack(); $value = $this->delegate->get($key, $nack); if ($value === $nack) { return $default; } $this->values[$key] = $value; return $value; } public function delete($key) { CRM_Utils_Cache::assertValidKey($key); unset($this->values[$key]); return $this->delegate->delete($key); } public function flush() { return $this->clear(); } public function clear() { $this->values = []; return $this->delegate->clear(); } public function has($key) { return $this->delegate->has($key); } }