You are here

function dmemcache_extension in Memcache API and Integration 6

Same name and namespace in other branches
  1. 7 dmemcache.inc \dmemcache_extension()

Determine which memcache extension to use: memcache or memcached.

By default prefer the 'Memcache' PHP extension, though the default can be overridden by setting memcache_extension in settings.php.

6 calls to dmemcache_extension()
dmemcache_close in ./dmemcache.inc
Close the connection to the memcache instance.
dmemcache_connect in ./dmemcache.inc
Initiate a connection to memcache.
dmemcache_instance in ./dmemcache.inc
Return a new memcache instance.
dmemcache_object in ./dmemcache.inc
Returns an Memcache object based on the bin requested. Note that there is nothing preventing developers from calling this function directly to get the Memcache object. Do this if you need functionality not provided by this API or if you need to use…
memcache_requirements in ./memcache.install
Implements hook_requirements().

... See full list

File

./dmemcache.inc, line 1021

Code

function dmemcache_extension() {
  static $extension = NULL;
  if ($extension === NULL) {

    // If an extension is specified in settings.php, use that when available.
    $preferred = variable_get('memcache_extension', NULL);
    if (isset($preferred) && class_exists($preferred, FALSE)) {
      $extension = ucfirst(strtolower($preferred));
    }
    elseif (class_exists('Memcache', FALSE)) {
      $extension = 'Memcache';
    }
    elseif (class_exists('Memcached', FALSE)) {
      $extension = 'Memcached';
    }
    else {
      $extension = FALSE;
    }
  }
  return $extension;
}