You are here

function dmemcache_set in Memcache API and Integration 5

Same name and namespace in other branches
  1. 5.2 dmemcache.inc \dmemcache_set()
  2. 6 dmemcache.inc \dmemcache_set()
  3. 7 dmemcache.inc \dmemcache_set()

Place an item into memcache

Parameters

$key The string with with you will retrieve this item later.:

$value The item to be stored.:

$exp Parameter expire is expiration time in seconds. If it's 0, the item never expires: (but memcached server doesn't guarantee this item to be stored all the time, it could be deleted from the cache to make place for other items).

$bin The name of the Drupal subsystem that is making this call. Examples could be: 'cache', 'alias', 'taxonomy term' etc. It is possible to map different $bin values to different memcache servers.

Return value

bool

4 calls to dmemcache_set()
cache_set in ./memcache.db.inc
Store data in the persistent cache.
cache_set in ./memcache.inc
Store data in memcache.
sess_regenerate in ./memcache-session.inc
sess_write in ./memcache-session.inc

File

./dmemcache.inc, line 32

Code

function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') {
  global $_memcache_statistics;
  $_memcache_statistics['set'][] = $key;
  $_memcache_statistics['bins'][] = $bin;
  if ($mc = dmemcache_object($bin)) {
    $full_key = dmemcache_key($key, $bin);
    if (!$mc
      ->set($full_key, $value, MEMCACHE_COMPRESSED, $exp)) {
      return FALSE;
    }
    else {
      return TRUE;
    }
  }
  return FALSE;
}