/** * Save a cache record directly. This method is implemented by the cache * drivers and used in Doctrine_Cache_Driver::save() * * @param string $id cache id * @param string $data data to cache * @param int $lifeTime if != false, set a specific lifetime for this cache record (null => infinite lifeTime) * @return boolean true if no problem */ protected function _doSave($id, $data, $lifeTime = false) { $pipeline = $this->_rediska->pipeline(); $pipeline->set($id, $data); if ($lifeTime) { $pipeline->expire($id, $lifeTime); } return $pipeline->execute(); }
public function __call($name, $args) { if (strtolower($name) == 'pipeline') { return $this->_rediska->pipeline(); } else { $command = $this->_rediska->getCommand($name, $args); $command->write(); return $command->read(); } }
/** * @see sfCache */ public function set($key, $data, $lifetime = null) { $lifetime = null === $lifetime ? $this->getOption('lifetime') : $lifetime; if ($lifetime < 1) { $response = $this->remove($key); } else { $pipeline = $this->_rediska->pipeline(); $origKey = $this->getKey($key); $metaKey = $this->getKey($key, 'lastmodified'); $result = $pipeline->set(array($origKey => $data, $metaKey => time()))->expire($origKey, $lifetime)->expire($metaKey, $lifetime)->execute(); $response = $result[0] && $result[1] && $result[2]; } return $response; }