diff options
-rw-r--r-- | it_cache.class | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/it_cache.class b/it_cache.class index 69f9498..081db65 100644 --- a/it_cache.class +++ b/it_cache.class @@ -56,7 +56,8 @@ static function get($key, $p = array()) $result = @$memcache->get($key); $success = !$memcache->getResultCode(); } - else + + if (!$success) $result = ($func = self::$_fetch_func) ? $func($key, $success) : null; return $success === false ? null : $result; @@ -76,11 +77,12 @@ 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']); - else + $success = $memsuccess = @$memcache->set($key, $value, $p['ttl']); + + if (!$success) $success = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null; - if (!$success && $p['safety'] == 1) + if ($memsuccess === false && $p['safety'] == 1) it::error(array_filter([ 'title' => ($p['distributed'] ? "memcache (" . ($memcache ? ($memcache->getResultMessage() . " on " . $memcache->getServerByKey($key)['host']) : "n/a") . ")" : self::$_store_func) . " in it_cache::put failed", 'body' => "key='$key'", |