Author: chabotc
Date: Mon Mar 16 13:13:27 2009
New Revision: 754885

URL: http://svn.apache.org/viewvc?rev=754885&view=rev
Log:
SHINDIG-973 by Nagy Attila: Making memcache pconnect optional

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

Modified: incubator/shindig/branches/1.0.x-incubating/php/config/container.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/php/config/container.php?rev=754885&r1=754884&r2=754885&view=diff
==============================================================================
--- incubator/shindig/branches/1.0.x-incubating/php/config/container.php 
(original)
+++ incubator/shindig/branches/1.0.x-incubating/php/config/container.php Mon 
Mar 16 13:13:27 2009
@@ -122,6 +122,9 @@
   // If you use CacheMemcache as caching backend, change these to the memcache 
server settings
   'cache_host' => 'localhost',
   'cache_port' => 11211,
+  // When using CacheMemcache, should we use pconnect? There are some reports 
that apache/mpm + memcache_pconnect can lead to segfaults
+  'cache_memcache_pconnect' => true,
+
   'cache_time' => 24 * 60 * 60,
   // If you use CacheFile as caching backend, this is the directory where it 
stores the temporary files
   'cache_root' => '/tmp/shindig',

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=754885&r1=754884&r2=754885&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:13:27 2009
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -18,7 +19,6 @@
  * under the License.
  */
 
-
 /*
  * This class impliments memcached based caching It'll generally be more
  * usefull in a multi-server envirionment then the file based caching,
@@ -80,7 +80,8 @@
   // I prefer lazy initalization since the cache isn't used every request
   // so this potentially saves a lot of overhead
   private function connect() {
-    if (! self::$connection = @memcache_pconnect($this->host, $this->port)) {
+    $func = Config::get('cache_memcache_pconnect') ? 'memcache_pconnect' : 
'memcache_connect';
+    if (! self::$connection = @$func($this->host, $this->port)) {
       throw new CacheException("Couldn't connect to memcache server");
     }
   }
@@ -110,8 +111,7 @@
   public function set($key, $value) {
     $this->check();
     // 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) {
+    if (@memcache_set(self::$connection, $key, array('time' => time(), 'data' 
=> $value), false, Config::Get('cache_time')) == false) {
       // Memcache write can fail occasionally, in a production environment
       // it's not a good idea to overreact it
       if (Config::get('debug')) {


Reply via email to