You are here

public static function MemcacheStorageAPI::set in Memcache Storage 7

Save data into memcached pool. Provide debug logging.

See also

http://www.php.net/manual/en/memcache.set.php

12 calls to MemcacheStorageAPI::set()
drupal_session_regenerate in includes/session.inc
Called when an anonymous user becomes authenticated or vice-versa.
MemcacheStorage::addCacheID in ./memcache_storage.inc
Add cache ID to the list of cache IDs which are used in the cache bin.
MemcacheStorage::clear in ./memcache_storage.inc
Implements DrupalCacheInterface::clear().
MemcacheStorage::getBinIndex in ./memcache_storage.inc
Load cache bin index. This index is part of memcache key and changes if cache bin should be cleared.
MemcacheStorage::increaseBinIndex in ./memcache_storage.inc
Increase cache bin index. This operation changes all memcache keys in selected cache bin so we simulate cache flush for it.

... See full list

File

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

Class

MemcacheStorageAPI
Integrates with memcache API.

Code

public static function set($cache_id, $data, $expire, $cache_bin = '') {

  // Get memcache object.
  $memcache = self::openConnection($cache_bin);

  // No memcache connection.
  if (empty($memcache)) {
    return FALSE;
  }

  // Build unique cache id.
  $cid = self::preprocessCacheKey($cache_id, $cache_bin);

  // Run initial debug actions.
  if (variable_get('memcache_storage_debug', FALSE)) {
    self::initialDebugActions();
  }

  // Set data to memcached pool.
  $result = FALSE;
  if ($memcache instanceof Memcache) {

    // Get compression mode.
    $compressed = variable_get('memcache_storage_compress_data') ? MEMCACHE_COMPRESSED : 0;
    $result = @$memcache
      ->set($cid, $data, $compressed, $expire);
  }
  elseif ($memcache instanceof Memcached) {
    $result = @$memcache
      ->set($cid, $data, $expire);
  }

  // Run final debug actions.
  if (variable_get('memcache_storage_debug', FALSE)) {
    self::finalDebugActions('set', $cache_bin, $cache_id, $cid, $result);
  }
  return $result;
}