isActive = false; if (DEFINED("MAPBENDER_VARIABLE_CACHE") && MAPBENDER_VARIABLE_CACHE) { if (DEFINED("MAPBENDER_CACHE_TYPE") && MAPBENDER_CACHE_TYPE != "") { $this->cacheType = MAPBENDER_CACHE_TYPE; switch ($this->cacheType) { case 'apc': $this->isActive = true; break; case 'apcu': $this->isActive = true; break; } } } } final public function cachedVariableFetch($key) { switch ($this->cacheType) { case "apc": return apc_fetch($key); break; case "apcu": return apcu_fetch($key); break; default: return false; break; } } final public function cachedVariableExists($key) { switch ($this->cacheType) { case "apc": //to allow older versions of apc - e.g. 3.1.3 which is used by debian squeeze if (function_exists('apc_exists')) { return apc_exists($key); } else { return (boolean)apc_fetch($key); } break; //for php 5.5+ - debian 8 onwards case "apcu": return (boolean)apcu_fetch($key); break; default: return false; break; } } final public function cachedVariableCreationTime($key) { switch ($this->cacheType) { case "apc": $cache = apc_cache_info('user'); if (empty($cache['cache_list'])) { return false; } foreach ($cache['cache_list'] as $entry) { if ($entry['info'] != $key) { continue; } return $entry['creation_time']; } return false; break; case "apcu": $cache = apcu_cache_info('user'); if (empty($cache['cache_list'])) { return false; } foreach ($cache['cache_list'] as $entry) { if ($entry['info'] != $key) { continue; } return $entry['creation_time']; } return false; break; default: return false; break; } return false; } final public function cachedVariableAdd($key, $value, $ttl = 0) { switch ($this->cacheType) { case "apc": return apc_add($key, $value, $ttl); break; case "apcu": return apcu_add($key, $value, $ttl); break; default: return false; break; } } final public function cachedVariableDelete($key) { switch ($this->cacheType) { case "apc": return apc_delete($key); break; case "apcu": return apcu_delete($key); break; default: return false; break; } } } ?>