summaryrefslogtreecommitdiff
path: root/it_cache.class
diff options
context:
space:
mode:
authorChristian Schneider2013-07-05 12:26:41 +0000
committerChristian Schneider2013-07-05 12:26:41 +0000
commite5065ef36b82a610cff572167bd5ea9af0771d00 (patch)
tree46916b12c5da1f90b9ec18f39a972af324954bc3 /it_cache.class
parent7802f477237473552bafc75253bcdead70e62c29 (diff)
downloaditools-e5065ef36b82a610cff572167bd5ea9af0771d00.tar.gz
itools-e5065ef36b82a610cff572167bd5ea9af0771d00.tar.bz2
itools-e5065ef36b82a610cff572167bd5ea9af0771d00.zip
Use apcu_ functions if they exists (PHP 5.5)
Diffstat (limited to 'it_cache.class')
-rw-r--r--it_cache.class9
1 files changed, 7 insertions, 2 deletions
diff --git a/it_cache.class b/it_cache.class
index 095becc..724651f 100644
--- a/it_cache.class
+++ b/it_cache.class
@@ -23,6 +23,8 @@
class it_cache
{
+ static $_fetch_func;
+ static $_store_func;
static function _defaults($p)
{
@@ -53,7 +55,7 @@ static function get($key, $p = array())
else if ($p['distributed'] && ($memcache = it_cache::_get_memcache($p)))
$result = @$memcache->get($key);
else
- $result = function_exists("apc_fetch") ? apc_fetch($key) : (function_exists("eaccelerator_get") ? eaccelerator_get($key) : null);
+ $result = ($func = self::$_fetch_func) ? $func($key) : null;
return $result;
}
@@ -77,7 +79,7 @@ static function put($key, $value, $p = array())
else
{
function_exists("eaccelerator_gc") && eaccelerator_gc();
- $result = function_exists("apc_store") ? apc_store($key, $value, $p['ttl']) : (function_exists("eaccelerator_put") ? eaccelerator_put($key, $value, $p['ttl']) : null);
+ $result = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null;
}
$GLOBALS['it_cache_local'][$key] = $value; # Also store local copy
@@ -104,4 +106,7 @@ static function _get_memcache($p)
}
+it_cache::$_fetch_func = function_exists("apcu_fetch") ? "apcu_fetch" : (function_exists("apc_fetch") ? "apc_fetch" : (function_exists("eaccelerator_get") ? "eaccelerator_get" : null));
+it_cache::$_store_func = function_exists("apcu_store") ? "apcu_store" : (function_exists("apc_store") ? "apc_store" : (function_exists("eaccelerator_put") ? "eaccelerator_put" : null));
+
?>