Exemple #1
0
 /**
  * Delete a cache entry based on id
  * @param   string   id of entry to delete
  * @param   integer  timeout of entry, if zero item is deleted immediately, otherwise the item will delete after the specified value in seconds
  * @return  boolean
  */
 public function delete($id, $timeout = 0)
 {
     $key = $this->_sanitize_id($id);
     if ($timeout == 0) {
         if (mb_substr($key, -2) == ":*") {
             $key = $this->_rediska->getKeysByPattern($key);
         }
         if ($key) {
             $this->_rediska->delete($key);
         }
     } else {
         $this->_rediska->setAndExpire($key, $this->get($id), $timeout);
     }
     return true;
 }
 /**
  * We manually remove keys as the redis glob style * == sfCache ** style
  *
  * @see sfCache
  */
 public function removePattern($pattern)
 {
     $pattern = $this->getKey($pattern);
     $regexp = self::patternToRegexp($pattern);
     $keys = $this->_rediska->getKeysByPattern($pattern);
     foreach ($keys as $key) {
         if (preg_match($regexp, $key)) {
             $this->remove(substr($key, strlen($this->getOption('prefix'))));
         }
     }
 }
 /**
  * Fetch an array of all keys stored in cache
  *
  * @return array Returns the array of cache keys
  */
 protected function _getCacheKeys()
 {
     return $this->_rediska->getKeysByPattern('*');
 }