You are here

protected function Redis_Cache::createEntryHash in Redis 7.3

Create cache entry

Parameters

string $cid:

mixed $data:

Return value

array

2 calls to Redis_Cache::createEntryHash()
Redis_Cache::set in lib/Redis/Cache.php
Stores data in the persistent cache.
Redis_CacheCompressed::createEntryHash in lib/Redis/CacheCompressed.php
Create cache entry
1 method overrides Redis_Cache::createEntryHash()
Redis_CacheCompressed::createEntryHash in lib/Redis/CacheCompressed.php
Create cache entry

File

lib/Redis/Cache.php, line 315

Class

Redis_Cache
Because those objects will be spawned during boostrap all its configuration must be set in the settings.php file.

Code

protected function createEntryHash($cid, $data, $expire = CACHE_PERMANENT) {
  list($flushPerm, $flushVolatile) = $this
    ->getLastFlushTime();
  if (CACHE_TEMPORARY === $expire) {
    $validityThreshold = max(array(
      $flushVolatile,
      $flushPerm,
    ));
  }
  else {
    $validityThreshold = $flushPerm;
  }
  $time = $this
    ->getValidChecksum($validityThreshold);
  $hash = array(
    'cid' => $cid,
    'created' => $time,
    'expire' => $expire,
  );

  // Let Redis handle the data types itself.
  if (!is_string($data)) {
    $hash['data'] = serialize($data);
    $hash['serialized'] = 1;
  }
  else {
    $hash['data'] = $data;
    $hash['serialized'] = 0;
  }
  return $hash;
}