protected function setKeySerialization($is_serialized, $key, $ttl) { if (!$is_serialized) { $this->redis->Del($this->serialize_key_prefix . $key); } else { if ($ttl > 0) { $this->redis->SetEX($this->serialize_key_prefix . $key, $ttl, 1); } else { $this->redis->Set($this->serialize_key_prefix . $key, 1); } } }
/** * Save variable in memory storage * * @param string $key - key * @param mixed $value - value * @param int $ttl - time to live (store) in seconds * @param array|string $tags - array of tags for this key * @return bool */ public function save($key, $value, $ttl = 259200, $tags = NULL) { $ttl = intval($ttl); if ($ttl < 1) { $ttl = self::max_ttl; } $set = $this->redis->SetEX($this->prefix . $key, $ttl, serialize($value)); if (!$set) { return false; } if (!empty($tags)) { $this->setTags($key, $tags); } return true; }