You are here

function dmemcache_get in Memcache API and Integration 6

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

Retrieve a value from the cache.

Parameters

$key The key with which the item was stored.:

$bin The bin in which the item was stored.:

Return value

The item which was originally saved or FALSE

13 calls to dmemcache_get()
cache_get in ./memcache.db.inc
Return data from the persistent cache. Data may be stored as either plain text or as serialized data. cache_get will automatically return unserialized objects and arrays.
cache_get in ./memcache.inc
Return data from the persistent cache.
dmemcache_piece_cache_get in ./dmemcache.inc
Determine if a key has multi-piece values.
dmemcache_piece_cache_set in ./dmemcache.inc
Track active keys with multi-piece values, necessary for efficient cleanup.
lock_acquire in ./memcache-lock-code.inc
Acquire (or renew) a lock, but do not block if it fails.

... See full list

File

./dmemcache.inc, line 246

Code

function dmemcache_get($key, $bin = 'cache') {
  $collect_stats = dmemcache_stats_init();
  $result = FALSE;
  $full_key = dmemcache_key($key, $bin);
  if ($mc = dmemcache_object($bin)) {
    $track_errors = ini_set('track_errors', '1');
    $php_errormsg = '';
    $result = @$mc
      ->get($full_key);
    if (is_object($result) && !empty($result->multi_part_data)) {

      // This is a multi-part value.
      $result = _dmemcache_get_pieces($result->data, $result->cid, $bin, $mc);
    }
    if (!empty($php_errormsg)) {
      register_shutdown_function('watchdog', 'memcache', 'Exception caught in dmemcache_get: !msg', array(
        '!msg' => $php_errormsg,
      ), WATCHDOG_WARNING);
      $php_errormsg = '';
    }
    ini_set('track_errors', $track_errors);
  }
  if ($collect_stats) {
    dmemcache_stats_write('get', $bin, array(
      $full_key => (bool) $result,
    ));
  }
  return $result;
}