/** * @param string $key * @param mixed $value * @param integer $ttl * @return mixed */ public function set($key, $value, $ttl = null) { if (!$this->exists($key)) { return wincache_ucache_add($keyword, $value, null === $ttl ? 0 : $ttl); } return wincache_ucache_set($keyword, $value, null === $ttl ? 0 : $ttl); }
/** * Adds a new item that is to be cached * * @param string $key * @param mixed $data * @param bool $overwrite * @return bool */ public function add($key, $data, $overwrite = false) { if ($overwrite == false) { return wincache_ucache_add($key, $data, $this->ttl()); } else { return wincache_ucache_set($key, $data, $this->ttl()); } }
public function add($key, $var, $expire= 0, $options= array()) { $added= wincache_ucache_add( $this->getCacheKey($key), $var, $expire ); return $added; }
function driver_set($keyword, $value = "", $time = 300, $option = array()) { if (isset($option['skipExisting']) && $option['skipExisting'] == true) { return wincache_ucache_add($keyword, $value, $time); } else { return wincache_ucache_set($keyword, $value, $time); } }
public function store($key, $value, $overwrite, $ttl = 0) { if ($overwrite) { return wincache_ucache_set($key, $value, $ttl); } else { // emits a warning if the key already exists return @wincache_ucache_add($key, $value, $ttl); } }
private function _storeData() { $this->_currentObject->detach(); $obj = serialize($this->_currentObject); if (wincache_ucache_exists($this->_cachePrefix . $this->_currentObjectID . '.cache')) { wincache_ucache_set($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, $this->_cacheTime); } else { wincache_ucache_add($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, $this->_cacheTime); } $this->_currentObjectID = $this->_currentObject = null; }
/** * Write an item to the cache for a given number of minutes. * * <code> * // Put an item in the cache for 15 minutes * Cache::put('name', 'Robin', 15); * </code> * * @param string $key * @param mixed $value * @param int $minutes * * @return bool|void */ public function put($key, $value, $minutes) { return wincache_ucache_add($this->key . $key, $value, $minutes * 60); }
/** * Adds multiple key-value pairs to cache. * The default implementation calls [[addValue()]] multiple times add values one by one. If the underlying cache * storage supports multiadd, this method should be overridden to exploit that feature. * @param array $data array where key corresponds to cache key while value is the value stored * @param integer $expire the number of seconds in which the cached values will expire. 0 means never expire. * @return array array of failed keys */ protected function addValues($data, $expire) { return wincache_ucache_add($data, null, $expire); }
/** * Store an item in the cache for a given number of minutes. * * @param string $key * @param mixed $value * @param int $minutes * @return void */ public function put($key, $value, $minutes) { wincache_ucache_add($this->prefix . $key, $value, $minutes * 60); }
/** * Stores a value identified by a key into cache if the cache does not contain this key. * This is the implementation of the method declared in the parent class. * * @param string $key the key identifying the value to be cached * @param string $value the value to be cached * @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire. * @return boolean true if the value is successfully stored into cache, false otherwise */ protected function addValue($key, $value, $expire) { return wincache_ucache_add($key, $value, $expire); }
/** * Store an item in the cache for a given number of minutes. * * @param string $key * @param mixed $value * @param int $minutes * @return void */ protected function storeItem($key, $value, $minutes) { wincache_ucache_add($this->prefix . $key, $value, $minutes * 60); }
{ $name = self::getMemoryName($name); return self::$objects['memcached']->increment($name, $step); } private static function memcached_decrement($name, $step = 1) { $name = self::getMemoryName($name); return self::$objects['memcached']->decrement($name, $step); } /*
/** * 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) { return wincache_ucache_add($id, $data, (int) $lifeTime); }
/** * Add to the cache * * Add a new variable to the cache that you will then be able * to retrieve using the $this->get($name) method. * * @param string $name The name of the cache variable to store. * @param string $value The value of the cache variable to store. * @param integer $expire When should it expire? Default: 900 seconds. * * @return boolean Depending on the success of the operation, * either true or false. */ public function add($name, $value, $expiry = 900) { return wincache_ucache_add($name, $value, $expiry); }
/** * 缓存一个变量到数据存储 * * @access public * * @param string $key 数据key * @param mixed $value 数据值 * @param int $expire 缓存时间(秒) * * @return boolean */ public function add($key, $value, $expire = null) { //参数分析 if (!$key) { return false; } $expire = is_null($expire) ? $this->_defaultOptions['expire'] : $expire; return wincache_ucache_add($key, $value, $expire); }
/** * Add multiple items. * * Options: * - namespace <string> optional * - The namespace to use (Default: namespace of object) * - tags <array> optional * - An array of tags * * @param array $keyValuePairs * @param array $options * @return boolean * @throws Exception * * @triggers addItems.pre(PreEvent) * @triggers addItems.post(PostEvent) * @triggers addItems.exception(ExceptionEvent) */ public function addItems(array $keyValuePairs, array $options = array()) { $baseOptions = $this->getOptions(); if (!$baseOptions->getWritable()) { return false; } $this->normalizeOptions($options); $args = new ArrayObject(array('keyValuePairs' => &$keyValuePairs, 'options' => &$options)); try { $eventRs = $this->triggerPre(__FUNCTION__, $args); if ($eventRs->stopped()) { return $eventRs->last(); } $internalKeyValuePairs = array(); $prefix = $options['namespace'] . $baseOptions->getNamespaceSeparator(); foreach ($keyValuePairs as $key => &$value) { $internalKey = $prefix . $key; $internalKeyValuePairs[$internalKey] =& $value; } $errKeys = wincache_ucache_add($internalKeyValuePairs, null, $options['ttl']); if ($errKeys !== array()) { throw new Exception\RuntimeException("wincache_ucache_add(<array>, null, {$options['ttl']}) failed for keys: " . "'" . implode("','", array_keys($errKeys)) . "'"); } $result = true; return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { return $this->triggerException(__FUNCTION__, $args, $e); } }
/** * Internal method to add multiple items. * * Options: * - ttl <float> * - The time-to-life * - namespace <string> * - The namespace to use * * @param array $normalizedKeyValuePairs * @param array $normalizedOptions * @return boolean * @throws Exception */ protected function internalAddItems(array &$normalizedKeyValuePairs, array &$normalizedOptions) { $internalKeyValuePairs = array(); $prefix = $normalizedOptions['namespace'] . $this->getOptions()->getNamespaceSeparator(); foreach ($normalizedKeyValuePairs as $normalizedKey => $value) { $internalKey = $prefix . $normalizedKey; $internalKeyValuePairs[$internalKey] = $value; } $errKeys = wincache_ucache_add($internalKeyValuePairs, null, $normalizedOptions['ttl']); if ($errKeys !== array()) { throw new Exception\RuntimeException("wincache_ucache_add(<array>, null, {$normalizedOptions['ttl']}) failed for keys: " . "'" . implode("','", array_keys($errKeys)) . "'"); } return true; }
/** * Internal method to add multiple items. * * @param array $normalizedKeyValuePairs * @return array Array of not stored keys * @throws Exception\ExceptionInterface */ protected function internalAddItems(array &$normalizedKeyValuePairs) { $options = $this->getOptions(); $namespace = $options->getNamespace(); if ($namespace === '') { return wincache_ucache_add($normalizedKeyValuePairs, null, $options->getTtl()); } $prefix = $namespace . $options->getNamespaceSeparator(); $internalKeyValuePairs = []; foreach ($normalizedKeyValuePairs as $normalizedKey => $value) { $internalKey = $prefix . $normalizedKey; $internalKeyValuePairs[$internalKey] = $value; } $result = wincache_ucache_add($internalKeyValuePairs, null, $options->getTtl()); // remove key prefic $prefixL = strlen($prefix); foreach ($result as &$key) { $key = substr($key, $prefixL); } return $result; }
/** * Adds data * * @param string $key * @param mixed $var * @param integer $expire * @return boolean */ function add($key, &$var, $expire = 0) { return wincache_ucache_add($key, serialize($var), $expire); }
/** * Adds a value to the shared memory storage. * * Sets a value to the storage if it doesn't exist, or fails if it does. * * @param string $key Name of key to associate the value with. * @param mixed $value Value for the specified key. * @param int $ttl Seconds to store the value. If set to 0 indicates no * time limit. * * @return bool TRUE on success, FALSE on failure. */ public function add($key, $value, $ttl = 0) { return wincache_ucache_add($this->persistentId . $key, $value, $ttl); }
/** * Internal method to add multiple items. * * Options: * - ttl <float> * - The time-to-life * - namespace <string> * - The namespace to use * * @param array $normalizedKeyValuePairs * @param array $normalizedOptions * @return array Array of not stored keys * @throws Exception\ExceptionInterface */ protected function internalAddItems(array & $normalizedKeyValuePairs, array & $normalizedOptions) { $internalKeyValuePairs = array(); $prefix = $normalizedOptions['namespace'] . $this->getOptions()->getNamespaceSeparator(); foreach ($normalizedKeyValuePairs as $normalizedKey => $value) { $internalKey = $prefix . $normalizedKey; $internalKeyValuePairs[$internalKey] = $value; } $result = wincache_ucache_add($internalKeyValuePairs, null, $normalizedOptions['ttl']); // remove key prefic foreach ($result as & $key) { $key = substr($key, $prefixL); } return $result; }
/** * @see wincache_ucache_add(); */ public function add($key, $value, $ttl = 0) { $result = wincache_ucache_add($key, $value, $ttl); $this->clearInfoArrays(); return $result; }
/** * Give (if possible) an extra lifetime to the given cache id * * @param string $id cache id * @param int $extraLifetime * @return boolean true if ok */ public function touch($id, $extraLifetime) { $tmp = wincache_ucache_get($id, $success); if ($success === false) { return false; } if (is_array($tmp)) { $data = $tmp[0]; $mtime = $tmp[1]; if (!isset($tmp[2])) { // because this record is only with 1.7 release // if old cache records are still there... return false; } $lifetime = $tmp[2]; $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime; if ($newLifetime <= 0) { return false; } wincache_ucache_add($id, array($data, time(), $newLifetime), $newLifetime); return true; } return false; }
/** * Clone the cell collection * * @param PHPExcel_Worksheet $parent The new worksheet * @return void */ public function copyCellCollection(PHPExcel_Worksheet $parent) { parent::copyCellCollection($parent); // Get a new id for the new file name $baseUnique = $this->getUniqueID(); $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; $cacheList = $this->getCellList(); foreach ($cacheList as $cellID) { if ($cellID != $this->currentObjectID) { $success = false; $obj = wincache_ucache_get($this->cachePrefix . $cellID . '.cache', $success); if ($success === false) { // Entry no longer exists in WinCache, so clear it from the cache array parent::deleteCacheData($cellID); throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in Wincache'); } if (!wincache_ucache_add($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) { $this->__destruct(); throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in Wincache'); } } } $this->cachePrefix = $newCachePrefix; }
/** * Adds multiple key-value pairs to cache. * The default implementation calls [[addValue()]] multiple times add values one by one. If the underlying cache * storage supports multiadd, this method should be overridden to exploit that feature. * @param array $data array where key corresponds to cache key while value is the value stored * @param integer $duration the number of seconds in which the cached values will expire. 0 means never expire. * @return array array of failed keys */ protected function addValues($data, $duration) { return wincache_ucache_add($data, null, $duration); }