summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2015-01-08 14:44:19 +0100
committerUrban Müller2015-01-08 14:44:19 +0100
commit3d73bfcaf9d8b50daf5e9c234d7889ce23e600e5 (patch)
tree7c4b4f11d3010ed2ddd21a25014a1aa6877a2427
parent09d83c329bf101d17f497413c4c4fa8c383c571e (diff)
downloaditools-3d73bfcaf9d8b50daf5e9c234d7889ce23e600e5.tar.gz
itools-3d73bfcaf9d8b50daf5e9c234d7889ce23e600e5.tar.bz2
itools-3d73bfcaf9d8b50daf5e9c234d7889ce23e600e5.zip
return null if key does not exists (out of band)
-rw-r--r--it_cache.class10
1 files changed, 5 insertions, 5 deletions
diff --git a/it_cache.class b/it_cache.class
index 5537b91..1a1ea02 100644
--- a/it_cache.class
+++ b/it_cache.class
@@ -41,7 +41,7 @@ static function _defaults($p)
/**
* Get value for specific key from cache. Can be mixed value but no objects.
* @param $key Key to get value for
- * @param $p['distributed'] Use distributed memcache [false]
+ * @param $p['distributed'] Use distributed memcache (scalars may become strings) [false]
* @return Value for given key or null
*/
static function get($key, $p = array())
@@ -51,18 +51,18 @@ static function get($key, $p = array())
if ($result = $GLOBALS['it_cache_local'][$key])
; # Use local copy
else if ($p['distributed'] && ($memcache = it_cache::_get_memcache($p)))
- $result = @$memcache->get($key);
+ $result = $success = @$memcache->get($key);
else
- $result = ($func = self::$_fetch_func) ? $func($key) : null;
+ $result = ($func = self::$_fetch_func) ? $func($key, $success) : null;
- return $result;
+ return $success === false ? null : $result;
}
/**
* Put value for specific key into cache. Can be mixed value but no objects.
* @param $key Key to put value with
* @param $value Value to put (mixed but no objects allowed)
- * @param $p['distributed'] Use distributed memcache [false]
+ * @param $p['distributed'] Use distributed memcache (scalars may become strings) [false]
* @param $p['ttl'] Time to live for this key/value-pair in seconds
* @return Returns $value
*/