You are here

function dmemcache_object_cluster in Memcache API and Integration 7

Ensure that we're working with a proper cluster array.

4 calls to dmemcache_object_cluster()
dmemcache_object in ./dmemcache.inc
Return a Memcache object for the specified bin.
memcache_admin_menu in memcache_admin/memcache_admin.module
Implements hook_menu().
memcache_enable in ./memcache.install
Implements hook_enable().
memcache_requirements in ./memcache.install
Implements hook_requirements().
2 string references to 'dmemcache_object_cluster'
memcache_admin_menu in memcache_admin/memcache_admin.module
Implements hook_menu().
memcache_admin_requirements in memcache_admin/memcache_admin.install
Implements hook_requirements().

File

./dmemcache.inc, line 1041
A memcache API for Drupal.

Code

function dmemcache_object_cluster($cluster) {
  if (!is_array($cluster)) {

    // Set defaults.
    $cluster = array(
      'cluster' => $cluster,
      'weight' => 1,
    );
  }
  if (!isset($cluster['cluster']) || !is_string($cluster['cluster'])) {

    // Cluster is required, complain if it's missing or invalid.
    register_shutdown_function('watchdog', 'memcache', 'Ignoring invalid or missing cluster definition, review your memcache_servers configuration.', array(), WATCHDOG_ERROR);
    return FALSE;
  }
  if (!isset($cluster['weight']) || !is_int($cluster['weight']) || $cluster['weight'] < 1) {

    // Weight is optional.
    $cluster['weight'] = 1;
  }
  return $cluster;
}