_timeout = intval($config['timeout']); } if (isset($config['prefix'])) { $this->_prefix = $config['prefix']; } } /** * @param $key * @param $value * * @return bool */ public function set($key, &$value) { if (!apc_store($this->_prefix . $key, $value, $this->_timeout)) { return FALSE; } return TRUE; } /** * @param $key * * @return mixed */ public function get($key) { return apc_fetch($this->_prefix . $key); } /** * @param $key * * @return bool|string[] */ public function delete($key) { return apc_delete($this->_prefix . $key); } public function flush() { $allinfo = apc_cache_info('user'); $keys = $allinfo['cache_list']; $prefix = $this->_prefix . "CRM_"; // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+ $lp = strlen($prefix); // Get prefix length foreach ($keys as $key) { $name = $key['info']; if ($prefix == substr($name, 0, $lp)) { // Ours? apc_delete($this->_prefix . $name); } } } }