Ejemplo n.º 1
0
 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 public function get($key)
 {
     $value = wincache_ucache_get($this->getPrefixWithLocale() . $key);
     if ($value !== false) {
         return $value;
     }
 }
Ejemplo n.º 2
0
 /**
  * 写入缓存
  * @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;
 }
Ejemplo n.º 3
0
 /**
  * @see SugarCacheAbstract::_getExternal()
  */
 protected function _getExternal($key)
 {
     if (!wincache_ucache_exists($key)) {
         return null;
     }
     return wincache_ucache_get($key);
 }
Ejemplo n.º 4
0
 /**
  * Get
  *
  * Look for a value in the cache. If it exists, return the data,
  * if not, return FALSE
  *
  * @param	string	$id	Cache Ide
  * @return	mixed	Value that is stored/FALSE on failure
  */
 public function get($id)
 {
     $success = FALSE;
     $data = wincache_ucache_get($id, $success);
     // Success returned by reference from wincache_ucache_get()
     return $success ? $data : FALSE;
 }
Ejemplo n.º 5
0
 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 protected function retrieveItem($key)
 {
     $value = wincache_ucache_get($this->prefix . $key);
     if ($value !== false) {
         return $value;
     }
 }
Ejemplo n.º 6
0
 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 public function get($key)
 {
     $value = wincache_ucache_get($this->prefix . $key);
     if ($value !== false) {
         return $value;
     }
 }
Ejemplo n.º 7
0
 /**
  * Fetch a cache record from this cache driver instance
  *
  * @param string $id cache id
  * @param boolean $testCacheValidity        if set to false, the cache validity won't be tested
  * @return mixed  Returns either the cached data or false
  */
 protected function _doFetch($id, $testCacheValidity = true)
 {
     $cache = wincache_ucache_get($id, $success);
     if ($success === false) {
         return false;
     }
     return $cache;
 }
Ejemplo n.º 8
0
 public function get($key)
 {
     if (wincache_ucache_exists($this->type . '_' . $key)) {
         $data = wincache_ucache_get($this->type . '_' . $key);
         return $data;
     }
     return false;
 }
Ejemplo n.º 9
0
 /**
  * 获取一个已经缓存的变量
  *
  * @access public
  *
  * @param string $key 缓存Key
  *
  * @return mixed
  */
 public function get($key)
 {
     //参数分析
     if ($key) {
         return false;
     }
     return wincache_ucache_get($key);
 }
Ejemplo n.º 10
0
 /**
  * Retrieve a cached value entry by id.
  * 
  *     // Retrieve cache entry from wincache group
  *     $data = Cache::instance('wincache')->get('foo');
  * 
  *     // Retrieve cache entry from wincache group and return 'bar' if miss
  *     $data = Cache::instance('wincache')->get('foo', 'bar');
  *
  * @param   string   id of cache to entry
  * @param   string   default value to return if cache miss
  * @return  mixed
  * @throws  Cache_Exception
  */
 public function get($id, $default = NULL)
 {
     // for ProfilerToolbar
     ProfilerToolbar::cacheLog('get', array_search($this, Cache::$instances), $id);
     // /for ProfilerToolbar
     $data = wincache_ucache_get($this->_sanitize_id($id), $success);
     return $success ? $data : $default;
 }
Ejemplo n.º 11
0
function cs_cache_load($name, $ttl = 0)
{
    $token = empty($ttl) ? $name : 'ttl_' . $name;
    if (wincache_ucache_exists($token)) {
        return wincache_ucache_get($token);
    }
    return false;
}
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function get($key)
 {
     $value = wincache_ucache_get($this->key($key), $success);
     if (!$success) {
         return null;
     }
     return $value;
 }
Ejemplo n.º 13
0
 /**
  * Fetches an item from the cache if it is still valid
  *
  * @param string $key
  * @return mixed
  */
 public function get($key)
 {
     $value = wincache_ucache_get($key, $success);
     if ($success) {
         return $value;
     }
     return false;
 }
Ejemplo n.º 14
0
 /**
  * @param string $key
  * @return mixed
  */
 public function get($key)
 {
     $value = wincache_ucache_get($key, $sucess);
     if ($sucess == false) {
         return null;
     }
     return $value;
 }
Ejemplo n.º 15
0
 /**
  * Get a value from the WinCache object cache
  *
  * @param $key String: cache key
  * @return mixed
  */
 public function get($key)
 {
     $val = wincache_ucache_get($key);
     if (is_string($val)) {
         $val = unserialize($val);
     }
     return $val;
 }
Ejemplo n.º 16
0
 protected function getWithToken($key, &$casToken, $flags = 0)
 {
     $val = wincache_ucache_get($key);
     $casToken = $val;
     if (is_string($val)) {
         $val = unserialize($val);
     }
     return $val;
 }
Ejemplo n.º 17
0
 protected function _get($key)
 {
     $success = false;
     $data = wincache_ucache_get($key, $success);
     if ($success === false) {
         return self::NOT_FOUND;
     }
     return $data;
 }
Ejemplo n.º 18
0
 /**
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
  * @return mixed The cached data, or false if the data doesn't exist, has expired, or if
  *     there was an error fetching it
  */
 public function read($key)
 {
     $time = time();
     $cachetime = intval(wincache_ucache_get($key . '_expires'));
     if ($cachetime < $time || $time + $this->settings['duration'] < $cachetime) {
         return false;
     }
     return wincache_ucache_get($key);
 }
Ejemplo n.º 19
0
 /**
  * @param \Psr\Cache\CacheItemInterface $item
  * @return mixed
  */
 protected function driverRead(CacheItemInterface $item)
 {
     $val = wincache_ucache_get($item->getKey(), $suc);
     if ($suc === false) {
         return null;
     } else {
         return $val;
     }
 }
Ejemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function get($key)
 {
     $cache = wincache_ucache_get($key, $success);
     if ($success === true) {
         return $cache;
     } else {
         return false;
     }
 }
Ejemplo n.º 21
0
 /**
  * Get a value from the WinCache object cache
  *
  * @param string $key Cache key
  * @param int $casToken [optional] Cas token
  * @return mixed
  */
 public function get($key, &$casToken = null)
 {
     $val = wincache_ucache_get($key);
     $casToken = $val;
     if (is_string($val)) {
         $val = unserialize($val);
     }
     return $val;
 }
Ejemplo n.º 22
0
 public function select($key)
 {
     $success = false;
     if (function_exists('wincache_ucache_get')) {
         $data = wincache_ucache_get($key, $success);
     } else {
         return getMessage('Cache', 'unsupported', 'Wincache');
     }
     return $success ? $data : false;
 }
Ejemplo n.º 23
0
 /**
  * Method to get a storage entry value from a key.
  *
  * @param   string  $key  The storage entry identifier.
  *
  * @return  CacheItemInterface
  *
  * @since   1.0
  */
 public function get($key)
 {
     $item = new Item($key);
     $success = true;
     $value = wincache_ucache_get($key, $success);
     if ($success) {
         $item->setValue($value);
     }
     return $item;
 }
Ejemplo n.º 24
0
 /**
  * {@inheritdoc}
  *
  * @param  string     $keyName
  * @param  integer    $lifetime
  * @return mixed|null
  */
 public function get($keyName, $lifetime = null)
 {
     $value = wincache_ucache_get($keyName, $success);
     if ($success === false) {
         return null;
     }
     $frontend = $this->getFrontend();
     $this->setLastKey($keyName);
     return $frontend->afterRetrieve($value);
 }
Ejemplo n.º 25
0
 /**
  * {@inheritdoc}
  *
  * @param  string     $keyName
  * @param  integer    $lifetime
  * @return mixed|null
  */
 public function get($keyName, $lifetime = null)
 {
     $prefixedKey = $this->getPrefixedIdentifier($keyName);
     $cachedContent = wincache_ucache_get($prefixedKey, $success);
     $this->_lastKey = $prefixedKey;
     if ($success === false) {
         return null;
     }
     return $this->_frontend->afterRetrieve($cachedContent);
 }
Ejemplo n.º 26
0
 public function fetchMultiple(array $keys)
 {
     $values = wincache_ucache_get($keys);
     foreach ($keys as $key) {
         if (!array_key_exists($key, $values)) {
             $values[$key] = false;
         }
     }
     return $values;
 }
Ejemplo n.º 27
0
 public function gc()
 {
     $allinfo = wincache_ucache_info();
     $keys = $allinfo['cache_entries'];
     $secret = $this->_hash;
     foreach ($keys as $key) {
         if (strpos($key['key_name'], $secret . '-cache-')) {
             wincache_ucache_get($key['key_name']);
         }
     }
 }
Ejemplo n.º 28
0
 /**
  * Fetches the data from shared memory and detects errors
  *
  * @param	string	title of the datastore item
  * @param	array	A reference to an array of items that failed and need to fetched from the database
  *
  * @return	boolean
  */
 protected function do_fetch($title, &$unfetched_items)
 {
     $ptitle = $this->prefix . $title;
     if (($data = wincache_ucache_get($ptitle)) === false) {
         // appears its not there, lets grab the data, lock the shared memory and put it in
         $unfetched_items[] = $title;
         return false;
     }
     $this->register($title, $data);
     return true;
 }
Ejemplo n.º 29
0
 function get($key)
 {
     $value = parent::get($key);
     if (!is_null($value)) {
         return $value;
     }
     if (EXTERNAL_CACHE_DEBUG) {
         SugarCache::log('grabbing via wincache_ucache_get(' . $this->_realKey($key) . ')');
     }
     return $this->_processGet($key, wincache_ucache_get($this->_realKey($key)));
 }
Ejemplo n.º 30
0
 function driver_get($keyword, $option = array())
 {
     // return null if no caching
     // return value if in caching
     $x = wincache_ucache_get($keyword, $suc);
     if ($suc == false) {
         return null;
     } else {
         return $x;
     }
 }