Author: chabotc
Date: Mon Mar 16 13:01:52 2009
New Revision: 754884

URL: http://svn.apache.org/viewvc?rev=754884&view=rev
Log:
SHINDIG-972 by Nagy Attila: CacheMemcache is too rigorous on write errors

Modified:
    
incubator/shindig/branches/1.0.x-incubating/php/src/common/sample/CacheMemcache.php

Modified: 
incubator/shindig/branches/1.0.x-incubating/php/src/common/sample/CacheMemcache.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/php/src/common/sample/CacheMemcache.php?rev=754884&r1=754883&r2=754884&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/php/src/common/sample/CacheMemcache.php
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/php/src/common/sample/CacheMemcache.php
 Mon Mar 16 13:01:52 2009
@@ -112,8 +112,17 @@
     // we store it with the cache_time default expiration so objects will 
atleast get cleaned eventually.
     if (@memcache_set(self::$connection, $key, array('time' => time(),
         'data' => $value), false, Config::Get('cache_time')) == false) {
-      throw new CacheException("Couldn't store data in cache");
+      // Memcache write can fail occasionally, in a production environment
+      // it's not a good idea to overreact it
+      if (Config::get('debug')) {
+        throw new CacheException("Couldn't store data in cache");
+      } else {
+        // If debug is off, we just signal the error in the return value,
+        // so those who depend on memcache writes could take adequate steps
+        return false;
+      }
     }
+    return true;
   }
 
   public function delete($key) {


Reply via email to