summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_cache.class36
1 files changed, 6 insertions, 30 deletions
diff --git a/it_cache.class b/it_cache.class
index c5b8b2c..df548b8 100644
--- a/it_cache.class
+++ b/it_cache.class
@@ -78,7 +78,7 @@ static function put($key, $value, $p = array())
$p = it_cache::_defaults($p);
if ($p['distributed'] && ($memcache = it_cache::_get_memcache($p)))
- $success = @$memcache->set($key, $value, $p['ttl']);
+ $success = @$memcache->set($key, $value, MEMCACHE_COMPRESSED, $p['ttl']);
else
$success = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null;
@@ -94,12 +94,12 @@ static function _get_memcache($p)
{
$memcache_id = "it_cache_memcache_" . $p['hostsfile'];
- if (!isset($GLOBALS[$memcache_id]) && class_exists("Memcached", false))
+ if (!isset($GLOBALS[$memcache_id]) && class_exists("Memcache", false))
{
- $memcache = new Memcached;
+ $memcache = new Memcache;
foreach (array_filter(it::replace(array('[#\s].*' => ""), file($p['hostsfile']))) as $host)
- $reachable += intval(@$memcache->addServer($host, 11211));
+ $reachable += intval(@$memcache->addServer($host));
$GLOBALS[$memcache_id] = $reachable ? $memcache : false;
}
@@ -107,31 +107,7 @@ static function _get_memcache($p)
return $GLOBALS[$memcache_id];
}
-static function _memcache_local_fetch($key, &$success)
-{
- if ($memcache = it_cache::_get_memcache(it_cache::_defaults(array())))
- {
- $result = @$memcache->get(self::_memcache_local_key($key));
- $success = !$memcache->getResultCode();
- }
-
- return $result;
-}
-
-static function _memcache_local_store($key, $value, $ttl)
-{
- if ($memcache = it_cache::_get_memcache(it_cache::_defaults(array())))
- $success = @$memcache->set(self::_memcache_local_key($key), $value, $ttl);
-
- return $success;
-}
-
-static function _memcache_local_key($key)
-{
- return "$key@" . gethostname();
-}
-
}
-it_cache::$_fetch_func = function_exists("apcu_fetch") ? "apcu_fetch" : (function_exists("apc_fetch") ? "apc_fetch" : "it_cache::_memcache_local_fetch");
-it_cache::$_store_func = function_exists("apcu_store") ? "apcu_store" : (function_exists("apc_store") ? "apc_store" : "it_cache::_memcache_local_store");
+it_cache::$_fetch_func = function_exists("apcu_fetch") ? "apcu_fetch" : (function_exists("apc_fetch") ? "apc_fetch" : null);
+it_cache::$_store_func = function_exists("apcu_store") ? "apcu_store" : (function_exists("apc_store") ? "apc_store" : null);