summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_cache.class4
1 files changed, 3 insertions, 1 deletions
diff --git a/it_cache.class b/it_cache.class
index 3fd154d..91916ea 100644
--- a/it_cache.class
+++ b/it_cache.class
@@ -30,6 +30,7 @@ static function _defaults($p)
'ttl' => 2,
'distributed' => false,
'hostsfile' => '/opt/ultra/etc/memcached.hosts',
+ 'safety' => 1,
);
if (!it::is_live() && !$p['distributed_on_devel'])
@@ -71,6 +72,7 @@ static function get($key, $p = array())
* @param $value Value to put (mixed but no objects allowed)
* @param $p['distributed'] Use distributed memcache (scalars may become strings) [false]
* @param $p['ttl'] Time to live for this key/value-pair in seconds
+ * @param $p['safety'] set to 0 to suppress an it::error in case of failure [1]
* @return Returns $value
*/
static function put($key, $value, $p = array())
@@ -82,7 +84,7 @@ static function put($key, $value, $p = array())
else
$success = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null;
- if (!$success)
+ if (!$success && $p['safety'] == 1)
it::error(array('title' => ($p['distributed'] ? "memcache" : self::$_store_func) . " in it_cache::put failed for key '$key'", 'id' => "it_cache_put", 'graceperiod' => 60, 'timewindow' => 10));
$GLOBALS['it_cache_local'][$key] = $value; # Also store local copy