You are here

function dmemcache_set in Memcache API and Integration 5.2

Same name and namespace in other branches
  1. 5 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

9 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.
dtestKeyValue in ./memcachetests.php
sess_regenerate in ./session-memcache.inc
sess_regenerate in ./session-memcache-db.inc
Called when an anonymous user becomes authenticated or vice-versa.

... See full list

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, TRUE, $exp)) {
      watchdog('memcache', 'Failed to set key: ' . $full_key, WATCHDOG_ERROR);
    }
    else {
      return TRUE;
    }
  }
  return FALSE;
}