diff options
author | Christian Schneider | 2016-05-10 16:24:38 +0200 |
---|---|---|
committer | Christian Schneider | 2016-05-10 16:24:38 +0200 |
commit | 60341f25054255ed45a3530f004ad7a3c9352eab (patch) | |
tree | 51ad64814aafe6255a01dc7553d056a9a55a32b5 | |
parent | b6f6f2b76786e84d40eac9b18c597aec8f92681c (diff) | |
parent | c3ac61c52780b91653efeeb88eb90739ee0a7b31 (diff) | |
download | itools-60341f25054255ed45a3530f004ad7a3c9352eab.tar.gz itools-60341f25054255ed45a3530f004ad7a3c9352eab.tar.bz2 itools-60341f25054255ed45a3530f004ad7a3c9352eab.zip |
Merge commit 'c3ac61c52780b91653efeeb88eb90739ee0a7b31'
-rw-r--r-- | it_cache.class | 8 | ||||
-rwxr-xr-x | tests/it_cache.t | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/it_cache.class b/it_cache.class index df548b8..d01df52 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, MEMCACHE_COMPRESSED, $p['ttl']); + $success = @$memcache->set($key, $value, $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("Memcache", false)) + if (!isset($GLOBALS[$memcache_id]) && class_exists("Memcached", false)) { - $memcache = new Memcache; + $memcache = new Memcached; foreach (array_filter(it::replace(array('[#\s].*' => ""), file($p['hostsfile']))) as $host) - $reachable += intval(@$memcache->addServer($host)); + $reachable += intval(@$memcache->addServer($host, 11211)); $GLOBALS[$memcache_id] = $reachable ? $memcache : false; } diff --git a/tests/it_cache.t b/tests/it_cache.t index 66fc2d3..8f804d4 100755 --- a/tests/it_cache.t +++ b/tests/it_cache.t @@ -32,14 +32,17 @@ is(it_cache::get('it_cache_t'.rand(1, 1000)), null, "local get unknown key"); $GLOBALS['debug_aslive'] = 1; it_cache::put('it_cache_d', 42, array('distributed' => 1)); +it_cache::put('it_cache_d', 0); unset($GLOBALS['it_cache_local']); is(intval(it_cache::get('it_cache_d', array('distributed' => 1))), 42, "distributed put/get number"); it_cache::put('it_cache_d', false, array('distributed' => 1)); +it_cache::put('it_cache_d', 1); unset($GLOBALS['it_cache_local']); is(boolval(it_cache::get('it_cache_d', array('distributed' => 1))), false, "distributed put/get false"); it_cache::put('it_cache_d', array(2), array('distributed' => 1)); +it_cache::put('it_cache_d', 0); unset($GLOBALS['it_cache_local']); is(it_cache::get('it_cache_d', array('distributed' => 1)), array(2), "distributed put/get array"); |