You are here

public static function MemcacheStorageAPI::openConnection in Memcache Storage 7

Connect to memcached clustes and returns memcached object on success.

Parameters

$bin: Cache bin name. i.e. 'cache' or 'cache_bootstrap'.

Return value

bool|object Memcache or memcached object is connection was successful. Otherwise FALSE.

6 calls to MemcacheStorageAPI::openConnection()
MemcacheStorageAPI::add in ./memcache_storage.api.inc
Save data into memcached pool if key doesn't exist. Provide debug logging.
MemcacheStorageAPI::delete in ./memcache_storage.api.inc
Delete value from memcached pool. Provide debug logging.
MemcacheStorageAPI::deleteMultiple in ./memcache_storage.api.inc
Delete multiple cache items from memcached pool. Provide debug logging.
MemcacheStorageAPI::getMultiple in ./memcache_storage.api.inc
Get values from memcache storage. Provide debug logging.
MemcacheStorageAPI::replace in ./memcache_storage.api.inc
Replace existing data in memcache pool. Provide debug logging.

... See full list

File

./memcache_storage.api.inc, line 28
Provide class that processes memcached operations.

Class

MemcacheStorageAPI
Integrates with memcache API.

Code

public static function openConnection($bin = '') {

  // Get name of cluster for the selected cache bin storage.
  $cluster_name = self::getCacheBinCluster($bin);

  // Connect to the cluster and get memcached object.
  if (!isset(self::$connections[$cluster_name])) {

    // Store memcached object as a static object, to avoid duplicate connections to the same
    // memcached cluster but for different cache bins.
    self::$connections[$cluster_name] = self::connectToCluster($cluster_name);
  }
  return self::$connections[$cluster_name];
}