You are here

protected function Redis_CacheCompressed::createEntryHash in Redis 7.3

Create cache entry

Parameters

string $cid:

mixed $data:

Return value

array

Overrides Redis_Cache::createEntryHash

File

lib/Redis/CacheCompressed.php, line 35

Class

Redis_CacheCompressed
This typically brings 80..85% compression in ~20ms/mb write, 5ms/mb read.

Code

protected function createEntryHash($cid, $data, $expire = CACHE_PERMANENT) {
  $hash = parent::createEntryHash($cid, $data, $expire);

  // Empiric level when compression makes sense.
  if (!$this->compressionSizeThreshold || strlen($hash['data']) > $this->compressionSizeThreshold) {
    $hash['data'] = gzcompress($hash['data'], $this->compressionRatio);
    $hash['compressed'] = true;
  }
  return $hash;
}