From 9b0e26cc2181ca9a36f757eb57a15dbfed3cc4d2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 31 Aug 2013 13:20:41 -0400 Subject: [PATCH] Deprecate MemcacheEngine and update defaults for Memcached People should switch to Memcached instead. The underlying extension is better maintained and provides improved features and performance. Collapse the persistent and persistentId settings, while also making non-persistent connections the default. Persistent connections should be an opt-in feature as having them enabled by default could go very wrong on shared hosting environments. --- app/Config/core.php | 10 ++++++---- lib/Cake/Cache/Engine/MemcacheEngine.php | 3 ++- lib/Cake/Cache/Engine/MemcachedEngine.php | 7 ++++--- .../Test/Case/Cache/Engine/MemcachedEngineTest.php | 3 +-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/Config/core.php b/app/Config/core.php index ba7a9d0ea..f1fd4aa56 100644 --- a/app/Config/core.php +++ b/app/Config/core.php @@ -309,18 +309,20 @@ * 'password' => 'password', //plaintext password (xcache.admin.pass) * )); * - * Memcache (http://www.danga.com/memcached/) + * Memcached (http://www.danga.com/memcached/) + * + * Uses the memcached extension. See http://php.net/memcached * * Cache::config('default', array( - * 'engine' => 'Memcache', //[required] + * 'engine' => 'Memcached', //[required] * 'duration' => 3600, //[optional] * 'probability' => 100, //[optional] * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string * 'servers' => array( * '127.0.0.1:11211' // localhost, default port 11211 * ), //[optional] - * 'persistent' => true, // [optional] set this to false for non-persistent connections - * 'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory) + * 'persistent' => 'my_connection', // [optional] The name of the persistent connection. + * 'compress' => false, // [optional] compress data in Memcached (slower, but uses less memory) * )); * * Wincache (http://php.net/wincache) diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 98b91d63b..17221e911 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -24,7 +24,8 @@ * control you have over expire times far in the future. See MemcacheEngine::write() for * more information. * - * @package Cake.Cache.Engine + * @package Cake.Cache.Engine + * @deprecated You should use the Memcached adapter instead. */ class MemcacheEngine extends CacheEngine { diff --git a/lib/Cake/Cache/Engine/MemcachedEngine.php b/lib/Cake/Cache/Engine/MemcachedEngine.php index 32c27d657..4b7202719 100755 --- a/lib/Cake/Cache/Engine/MemcachedEngine.php +++ b/lib/Cake/Cache/Engine/MemcachedEngine.php @@ -46,6 +46,8 @@ class MemcachedEngine extends CacheEngine { * - servers = string or array of memcached servers, default => 127.0.0.1. If an * array MemcacheEngine will use them as a pool. * - compress = boolean, default => false + * - persistent = string The name of the persistent connection. All configurations using + * the same persistent value will share a single underlying connection. * * @var array */ @@ -72,8 +74,7 @@ class MemcachedEngine extends CacheEngine { 'engine' => 'Memcached', 'servers' => array('127.0.0.1'), 'compress' => false, - 'persistent' => true, - 'persistentId' => 'mc', + 'persistent' => false, 'login' => null, 'password' => null, ); @@ -87,7 +88,7 @@ class MemcachedEngine extends CacheEngine { return true; } - $this->_Memcached = new Memcached($this->settings['persistent'] ? $this->settings['persistentId'] : null); + $this->_Memcached = new Memcached($this->settings['persistent'] ? (string)$this->settings['persistent'] : null); $this->_setOptions(); if (count($this->_Memcached->getServerList())) { diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php index a4539771f..7ca8e4155 100755 --- a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php @@ -97,8 +97,7 @@ class MemcachedEngineTest extends CakeTestCase { 'duration' => 3600, 'probability' => 100, 'servers' => array('127.0.0.1'), - 'persistent' => true, - 'persistentId' => 'mc', + 'persistent' => false, 'compress' => false, 'engine' => 'Memcached', 'login' => null,