/** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { if (!$ttl) { $ttl = $this->ttl; } wincache_ucache_set($key, $value); }
/** * Store value in cache * @return mixed|FALSE * @param $key string * @param $val mixed * @param $ttl int **/ function set($key, $val, $ttl = 0) { $fw = Base::instance(); if (!$this->dsn) { return TRUE; } $ndx = $this->prefix . '.' . $key; $time = microtime(TRUE); if ($cached = $this->exists($key)) { list($time, $ttl) = $cached; } $data = $fw->serialize(array($val, $time, $ttl)); $parts = explode('=', $this->dsn, 2); switch ($parts[0]) { case 'apc': case 'apcu': return apc_store($ndx, $data, $ttl); case 'redis': return $this->ref->set($ndx, $data, array('ex' => $ttl)); case 'memcache': return memcache_set($this->ref, $ndx, $data, 0, $ttl); case 'wincache': return wincache_ucache_set($ndx, $data, $ttl); case 'xcache': return xcache_set($ndx, $data, $ttl); case 'folder': return $fw->write($parts[1] . $ndx, $data); } return FALSE; }
/** * 写入缓存 * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) { \think\Cache::$writeTimes++; if (is_null($expire)) { $expire = $this->options['expire']; } $name = $this->options['prefix'] . $name; if (wincache_ucache_set($name, $value, $expire)) { if ($this->options['length'] > 0) { // 记录缓存队列 $queue = wincache_ucache_get('__info__'); if (!$queue) { $queue = []; } if (false === array_search($name, $queue)) { array_push($queue, $name); } if (count($queue) > $this->options['length']) { // 出列 $key = array_shift($queue); // 删除缓存 wincache_ucache_delete($key); } wincache_ucache_set('__info__', $queue); } return true; } return false; }
/** * {@inheritdoc} * * @param string $keyName * @param string $content * @param integer $lifetime * @param boolean $stopBuffer * @throws \Phalcon\Cache\Exception */ public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) { if ($keyName === null) { $lastKey = $this->_lastKey; } else { $lastKey = $keyName; } if (!$lastKey) { throw new Exception('The cache must be started first'); } $frontend = $this->getFrontend(); if ($content === null) { $content = $frontend->getContent(); } //Get the lifetime from the frontend if ($lifetime === null) { $lifetime = $frontend->getLifetime(); } wincache_ucache_set($lastKey, $frontend->beforeStore($content), $lifetime); $isBuffering = $frontend->isBuffering(); //Stop the buffer, this only applies for Phalcon\Cache\Frontend\Output if ($stopBuffer) { $frontend->stop(); } //Print the buffer, this only applies for Phalcon\Cache\Frontend\Output if ($isBuffering) { echo $content; } $this->_started = false; }
/** * Adds a variable in user cache and overwrites a variable if it already exists in the cache * * @param string $key Store the variable using this $key value. * If a variable with same $key is already present the function will overwrite the previous value with the new one. * @param mixed $buff Value of a variable to store. $value supports all data types except resources, such as file handlers. * @param int $valid_time Time for the variable to live in the cache in seconds. * After the value specified in ttl has passed the stored variable will be deleted from the cache. * If no ttl is supplied, use the default valid time CacheWincache::valid_time. * @return bool Returns true on success or false on failure. */ function put($key, $buff, $valid_time = 0) { if ($valid_time == 0) { $valid_time = $this->valid_time; } return wincache_ucache_set(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time); }
/** * Adds a variable in user cache and overwrites a variable if it already exists in the cache * * @param string $key Store the variable using this $key value. * If a variable with same $key is already present the function will overwrite the previous value with the new one. * @param mixed $buff Value of a variable to store. $value supports all data types except resources, such as file handlers. * @param int $valid_time Time for the variable to live in the cache in seconds. * After the value specified in ttl has passed the stored variable will be deleted from the cache. * If no ttl is supplied, use the default valid time CacheWincache::valid_time. * @return bool Returns true on success or false on failure. */ function put($key, $buff, $valid_time = 0) { if ($valid_time == 0) { $valid_time = $this->valid_time; } return wincache_ucache_set(md5(_XE_PATH_ . $key), array($_SERVER['REQUEST_TIME'], $buff), $valid_time); }
/** * Store a value in the WinCache object cache * * @param $key String: cache key * @param $value Mixed: object to store * @param $expire Int: expiration time * @return bool */ public function set($key, $value, $expire = 0) { $result = wincache_ucache_set($key, serialize($value), $expire); /* wincache_ucache_set returns an empty array on success if $value was an array, bool otherwise */ return is_array($result) && $result === array() || $result; }
/** * @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); }
/** * Write data for key into cache * * @param string $key Identifier for the data * @param mixed $value Data to be cached * @param integer $duration How long to cache the data, in seconds * @return boolean True if the data was successfully cached, false on failure */ public function write($key, $value, $duration) { $expires = time() + $duration; $data = array($key . '_expires' => $expires, $key => $value); $result = wincache_ucache_set($data, null, $duration); return empty($result); }
public function insert($key, $var, $time = 60, $expressed = false) { if (function_exists('wincache_ucache_set')) { return wincache_ucache_set($key, $var, $time); } else { return getMessage('Cache', 'unsupported', 'Wincache'); } }
public function create($key, $value) { try { return wincache_ucache_set($key, $value); } catch (Exception $ex) { throw new Exception($ex->getMessage(), $ex->getCode()); } }
/** * (Plug-in replacement for memcache API) Delete data from the persistant cache. * * @param mixed Key name */ function delete($key) { // Update list of e-objects global $ECACHE_OBJECTS; unset($ECACHE_OBJECTS[$key]); wincache_ucache_set(get_file_base() . 'ECACHE_OBJECTS', $ECACHE_OBJECTS, 0); wincache_ucache_delete($key); }
/** * 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()); } }
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 replace($key, $var, $expire = 0, $options = array()) { $replaced = false; if (wincache_ucache_exists($key)) { $replaced = wincache_ucache_set($this->getCacheKey($key), $var, $expire); } return $replaced; }
/** * 设置一个缓存变量 * * @access public * * @param string $key 缓存Key * @param mixed $value 缓存内容 * @param int $expire 缓存时间(秒) * * @return boolean */ public function set($key, $value, $expire = null) { //参数分析 if ($key) { return false; } $expire = is_null($expire) ? $this->_defaultOptions['expire'] : $expire; return wincache_ucache_set($key, $value, $expire); }
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); } }
/** * 写入缓存 * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) { if (is_null($expire)) { $expire = $this->options['expire']; } $name = $this->options['prefix'] . $name; if (wincache_ucache_set($name, $value, $expire)) { return true; } return false; }
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; }
/** * @param \Psr\Cache\CacheItemInterface $item * @return mixed * @throws \InvalidArgumentException */ protected function driverWrite(CacheItemInterface $item) { /** * Check for Cross-Driver type confusion */ if ($item instanceof Item) { return wincache_ucache_set($item->getKey(), $this->driverPreWrap($item), $item->getTtl()); } else { throw new \InvalidArgumentException('Cross-Driver type confusion detected'); } }
function cs_cache_save($name, $content, $ttl = 0) { $token = empty($ttl) ? $name : 'ttl_' . $name; cs_cache_delete($token); if (is_bool($content)) { cs_error($name, 'cs_cache_save - It is not allowed to just store a boolean'); } else { wincache_ucache_set($token, $content, $ttl); } return $content; }
/** +---------------------------------------------------------- * 写入缓存 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) +---------------------------------------------------------- * @return boolen +---------------------------------------------------------- */ public function set($name, $value, $expire = null) { N('cache_write', 1); if (is_null($expire)) { $expire = $this->options['expire']; } if (wincache_ucache_set($name, $value, $expire)) { if ($this->options['length'] > 0) { // 记录缓存队列 $this->queue($name); } return true; } return false; }
/** * 写入缓存 * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 * @param integer $expire 有效时间(秒) * @return boolean */ public function set($name, $value, $expire = null) { if (is_null($expire)) { $expire = $this->options['expire']; } $key = $this->getCacheKey($name); if ($this->tag && !$this->has($name)) { $first = true; } if (wincache_ucache_set($key, $value, $expire)) { isset($first) && $this->setTagItem($key); return true; } return false; }
function set($key, $value) { parent::set($key, $value); // caching is turned off if (!$GLOBALS['external_cache_enabled']) { return; } $external_key = $this->_realKey($key); if (EXTERNAL_CACHE_DEBUG) { SugarCache::log("Step 3: Converting key ({$key}) to external key ({$external_key})"); } wincache_ucache_set($external_key, $value, $this->timeout); if (EXTERNAL_CACHE_DEBUG) { SugarCache::log("Step 4: Added key to Wincache cache {$external_key} with value ({$value}) to be stored for " . EXTERNAL_CACHE_INTERVAL_SECONDS . " seconds"); } }
/** * {@inheritdoc} */ function loadClass($class) { // Look if the cache has anything for this class. if ($file = wincache_ucache_get($this->prefix . $class)) { if (is_file($file)) { require $file; return; } wincache_ucache_delete($this->prefix . $class); } // Resolve cache miss. $api = new LoadClassGetFileInjectedApi($class); if ($this->finder->apiFindFile($api, $class)) { wincache_ucache_set($this->prefix . $class, $api->getFile()); } }
private function _storeData() { $this->_currentObject->detach(); $obj = serialize($this->_currentObject); if (wincache_ucache_exists($this->_cachePrefix . $this->_currentObjectID . '.cache')) { if (!wincache_ucache_set($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, $this->_cacheTime)) { $this->__destruct(); throw new Exception('Failed to store cell ' . $cellID . ' in WinCache'); } } else { if (!wincache_ucache_add($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, $this->_cacheTime)) { $this->__destruct(); throw new Exception('Failed to store cell ' . $cellID . ' in WinCache'); } } $this->_currentObjectID = $this->_currentObject = null; }
/** * 存数据 * * @param string/array $key 支持多存 * @param $data Value 多存时此项可空 * @param $lifetime 有效期,默认3600,即1小时,0表示最大值30天(2592000) * @return boolean */ public function set($key, $value = null, $lifetime = 3600) { \Core::debug()->info($key, 'wincache set key'); if (\is_array($key)) { $return = true; foreach ($key as $k => &$v) { static::_format_data($v); $s = \wincache_ucache_set($k, $v, $lifetime); if (false === $s) { $return = false; } } return $return; } else { static::_format_data($value); return \wincache_ucache_set($key, $value, $lifetime); } }
/** * Store cell data in cache for the current cell object if it's "dirty", * and the 'nullify' the current cell object * * @return void * @throws PHPExcel_Exception */ protected function storeData() { if ($this->currentCellIsDirty && !empty($this->currentObjectID)) { $this->currentObject->detach(); $obj = serialize($this->currentObject); if (wincache_ucache_exists($this->cachePrefix . $this->currentObjectID . '.cache')) { if (!wincache_ucache_set($this->cachePrefix . $this->currentObjectID . '.cache', $obj, $this->cacheTime)) { $this->__destruct(); throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in WinCache'); } } else { if (!wincache_ucache_add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, $this->cacheTime)) { $this->__destruct(); throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in WinCache'); } } $this->currentCellIsDirty = false; } $this->currentObjectID = $this->currentObject = null; }
/** * 存数据 * * @param string/array $key 支持多存 * @param $data Value 多存时此项可空 * @param $lifetime 有效期,默认3600,即1小时,0表示最大值30天(2592000) * @return boolean */ public function set($key, $value = null, $lifetime = 3600) { if (IS_DEBUG) { Core::debug()->info($key, 'wincache set key'); } if (is_array($key)) { $return = true; foreach ($key as $k => &$v) { Cache_Driver_WinCache::_format_data($v); $s = wincache_ucache_set($k, $v, $lifetime); if (false === $s) { $return = false; } } return $return; } else { Cache_Driver_WinCache::_format_data($value); return wincache_ucache_set($key, $value, $lifetime); } }
/** * {@inheritdoc} * * @param string $keyName * @param string $content * @param integer $lifetime * @param boolean $stopBuffer * @throws \Phalcon\Cache\Exception */ public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) { if ($keyName === null) { $lastKey = $this->_lastKey; } else { $lastKey = $this->getPrefixedIdentifier($keyName); } if (!$lastKey) { throw new Exception('The cache must be started first'); } /** @var \Phalcon\Cache\FrontendInterface $frontend */ $frontend = $this->getFrontend(); if ($content === null) { $cachedContent = $frontend->getContent(); } else { $cachedContent = $content; } $preparedContent = $frontend->beforeStore($cachedContent); if ($lifetime === null) { $lifetime = $this->_lastLifetime; if ($lifetime === null) { $ttl = $frontend->getLifetime(); } else { $ttl = $lifetime; } } else { $ttl = $lifetime; } wincache_ucache_set($lastKey, $preparedContent, $ttl); $isBuffering = $frontend->isBuffering(); if ($stopBuffer) { $frontend->stop(); } if ($isBuffering) { echo $content; } $this->_started = false; }