You are here

public function Redis_CacheCompressed::__construct in Redis 7.3

Overrides Redis_Cache::__construct

File

lib/Redis/CacheCompressed.php, line 14

Class

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

Code

public function __construct($bin) {
  parent::__construct($bin);
  $this->compressionSizeThreshold = (int) variable_get('cache_compression_size_threshold', 100);
  if ($this->compressionSizeThreshold < 0) {
    trigger_error('cache_compression_size_threshold must be 0 or a positive integer, negative value found, switching back to default 100', E_USER_WARNING);
    $this->compressionSizeThreshold = 100;
  }

  // Minimum compression level (1) has good ratio in low time.
  $this->compressionRatio = (int) variable_get('cache_compression_ratio', 1);
  if ($this->compressionRatio < 1 || 9 < $this->compressionRatio) {
    trigger_error('cache_compression_ratio must be between 1 and 9, out of bounds value found, switching back to default 1', E_USER_WARNING);
    $this->compressionRatio = 1;
  }
}