Commit 432a4d11 authored by Jeremy's avatar Jeremy
Browse files

Add ability to set options with memcached PECL package. Set sane defaults. ...

Add ability to set options with memcached PECL package.  Set sane defaults.  Document.  Patch thanks to nnewton.
parent a9a4a50b
......@@ -178,3 +178,34 @@ See http://drupal.org/node/273824
A module offering a UI for memcache is included. It provides stats, a
way to clear the cache, and an interface to organize servers/bins/clusters.
## Memcached PECL Extension Support
We also now support the Memcached PECL extension. If you install this extension,
it will be used by default. This new extension backends to libmemcached and
allows you to use some of the newer advanced features in memcached 1.4.
NOTE: It is important to realize that the memcache php.ini options do not impact
the memcached extension, this new extension doesn't read in options that way.
Instead, it takes options directly from Drupal. Because of this, you must
configure memcached in settings.php. Please look here for possible options:
http://us2.php.net/manual/en/memcached.constants.php
An example configuration block is below, this block also illustrates our
default options. These will be set even if you add nothing to settings.php.
$conf['memcache_options'] = array(
Memcached::OPT_COMPRESSION => false,
Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
Memcached::OPT_BINARY_PROTOCOL => true,
);
These are as follows:
* Turn off compression, as compression takes more CPU cyles than it's worth
for most users
* Turn on consistent distribution, which allows you to add/remove servers
easily
* Turn on the binary protocol, which is more advanced and faster
......@@ -248,6 +248,15 @@ function dmemcache_object($bin = NULL, $flush = FALSE) {
// Create a new Memcache object. Each cluster gets its own Memcache object.
if (class_exists('Memcached')) {
$memcache = new Memcached;
$default_opts = array (
Memcached::OPT_COMPRESSION => false,
Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
Memcached::OPT_BINARY_PROTOCOL => true,
);
$memconf = variable_get('memcache_options', $default_opts);
foreach ($memconf as $key => $value) {
$memcache->setOption($key, $value);
}
}
else if (class_exists('Memcache')) {
$memcache = new Memcache;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment