From 481159435fa6d3acc2532e1c3af181c2375a1e9d Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 16 Oct 2013 13:33:18 +0000 Subject: return written value from it_cache::put --- it_cache.class | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'it_cache.class') diff --git a/it_cache.class b/it_cache.class index 724651f..3641d59 100644 --- a/it_cache.class +++ b/it_cache.class @@ -66,7 +66,7 @@ static function get($key, $p = array()) * @param $value Value to put (mixed but no objects allowed) * @param $p['distributed'] Use distributed memcache [false] * @param $p['ttl'] Time to live for this key/value-pair in seconds - * @return Boolean if value was put into cache + * @return Returns $value */ static function put($key, $value, $p = array()) { @@ -74,17 +74,20 @@ static function put($key, $value, $p = array()) if ($p['distributed'] && ($memcache = it_cache::_get_memcache($p))) { - $result = @$memcache->set($key, $value, MEMCACHE_COMPRESSED, $p['ttl']); + $success = @$memcache->set($key, $value, MEMCACHE_COMPRESSED, $p['ttl']); } else { function_exists("eaccelerator_gc") && eaccelerator_gc(); - $result = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null; + $success = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null; } + if (!$success) + it::error("it_cache::put failed"); + $GLOBALS['it_cache_local'][$key] = $value; # Also store local copy - return $result; + return $value; } static function _get_memcache($p) -- cgit v1.2.3