Beispiel #1
0
 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 public function get($key)
 {
     $value = xcache_get($this->getPrefixWithLocale() . $key);
     if (isset($value)) {
         return $value;
     }
 }
Beispiel #2
0
 public function get($key)
 {
     if (!$key) {
         return false;
     }
     return xcache_isset($key) ? xcache_get($key) : false;
 }
Beispiel #3
0
 /**
  * 读取缓存,失败或缓存撒失效时返回 false
  *
  * @param string $id
  *
  * @return mixed
  */
 function get($id)
 {
     if (xcache_isset($id)) {
         return xcache_get($id);
     }
     return false;
 }
Beispiel #4
0
 /**
  * Gets a value from the variable store
  * @param string $key The key of the variable
  * @param mixed $default The default value for when the key is not set
  * @return mixed The value of the variable if it exists, the provided default value otherwise
  */
 public function get($key, $default = null)
 {
     if (xcache_isset($key)) {
         return xcache_get($key);
     }
     return $default;
 }
Beispiel #5
0
 /**
  * Get cache record implementation
  * @param string $id
  * @param boolean $doNotTestCacheValidity
  * @return string
  */
 public function realGet($id, $doNotTestCacheValidity = false)
 {
     if (xcache_isset($id)) {
         return xcache_get($id);
     }
     return null;
 }
Beispiel #6
0
 public static function get($key)
 {
     global $config, $debug;
     $key = $config['cache']['prefix'] . $key;
     $data = false;
     switch ($config['cache']['enabled']) {
         case 'memcached':
             if (!self::$cache) {
                 self::init();
             }
             $data = self::$cache->get($key);
             break;
         case 'apc':
             $data = apc_fetch($key);
             break;
         case 'xcache':
             $data = xcache_get($key);
             break;
         case 'php':
             $data = isset(self::$cache[$key]) ? self::$cache[$key] : false;
             break;
         case 'redis':
             if (!self::$cache) {
                 self::init();
             }
             $data = json_decode(self::$cache->get($key), true);
             break;
     }
     if ($config['debug']) {
         $debug['cached'][] = $key . ($data === false ? ' (miss)' : ' (hit)');
     }
     return $data;
 }
 function cacheget($name)
 {
     if (!$this->cache_type) {
         return;
     }
     $rdata2 = false;
     if (!$this->thestorage) {
         switch ($this->cache_type) {
             case 1:
                 if ($this->connect()) {
                     $rdata = $this->mchandle->get(VBSEO_CACHE_VAR);
                 }
                 break;
             case 2:
                 $rdata = apc_fetch(VBSEO_CACHE_VAR);
                 break;
             case 3:
                 if (xcache_isset(VBSEO_CACHE_VAR)) {
                     $rdata = xcache_get(VBSEO_CACHE_VAR);
                 }
                 break;
             case 4:
                 $rdata = eaccelerator_get(VBSEO_CACHE_VAR);
                 break;
         }
         if ($rdata) {
             $this->thestorage = unserialize($rdata);
         } else {
             $this->thestorage = array();
         }
     }
     $rdata2 = $this->thestorage[$name];
     return $rdata2;
 }
Beispiel #8
0
 /**
  * Get
  *
  * Since this is the dummy class, it's always going to return FALSE.
  *
  * @param 	string
  * @return 	Boolean		FALSE
  */
 public function readCache($type, $name, $ID, $onlyCheck = FALSE)
 {
     $this->getInstance();
     $originalID = $ID;
     if (isset($_POST) && count($_POST) > 0) {
         $ID = $ID . md5(serialize($_POST));
     }
     self::logMessage('cache', "Cche xcache reading {$type} - {$name} - {$ID}.");
     $item_expiration = $this->getCacheItemExpiration($type, $name, $originalID);
     if (is_array($item_expiration)) {
         $item_properties = $item_expiration;
         $name .= '-' . $item_properties[0];
         $item_expiration = $item_properties[1];
     }
     if ($item_expiration == FALSE) {
         $item_expiration = $this->getCacheConfigItem('default', $type);
         if ($item_expiration == FALSE) {
             return FALSE;
         }
     }
     $cache = xcache_get($type . '-' . $name . '-' . $ID);
     if ($cache == FALSE) {
         return FALSE;
     }
     self::logMessage('cache', 'Cache xcache read OK: ' . $type . '/' . $name . '/' . $ID);
     if ($cache && $onlyCheck) {
         return TRUE;
     }
     return unserialize($cache);
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 public function expired($key, $mins)
 {
     $key = $this->getName($key);
     if (xcache_isset($key)) {
         return time() - xcache_get($key)['created'] > $mins * 60;
     }
 }
 /**
  * 写入缓存
  * @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 (xcache_set($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $queue = xcache_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);
                 // 删除缓存
                 xcache_unset($key);
             }
             xcache_set('__info__', $queue);
         }
         return true;
     }
     return false;
 }
Beispiel #11
0
 public function get($key)
 {
     if (xcache_isset($key)) {
         return xcache_get($key);
     }
     return FALSE;
 }
 public function get($id)
 {
     if (xcache_isset($id)) {
         return xcache_get($id);
     }
     return NULL;
 }
Beispiel #13
0
 /**
  * Returns cached value by key or false if there is no cache entry for the given key
  *
  * @param string $key
  * @return bool|mixed
  */
 public function get($key)
 {
     if ($value = xcache_get($this->prepareKey($key))) {
         return $this->unserializeCompound($value);
     }
     return false;
 }
Beispiel #14
0
 public function __get($index)
 {
     if (function_exists('xcache_get')) {
         return xcache_get($index);
     }
     return null;
 }
Beispiel #15
0
 function get($key)
 {
     if (!ini_get('xcache.var_size')) {
         return FALSE;
     }
     return unserialize(strval(@xcache_get($key)));
 }
 /**
  * Get data from shared memory cache
  *
  * @param  string $sKey - file name
  * @param  int    $iTTL - time to live
  * @return the    data is got from cache.
  */
 function getData($sKey, $iTTL = false)
 {
     if (!xcache_isset($sKey)) {
         return null;
     }
     return xcache_get($sKey);
 }
Beispiel #17
0
 /**
  * Retrieve an item from the cache.
  *
  * @param string The name of the cache
  * @param boolean True if we should do a hard refresh
  * @return mixed Cache data if successful, false if failure
  */
 function fetch($name, $hard_refresh = false)
 {
     if (!xcache_isset($this->unique_id . "_" . $name)) {
         return false;
     }
     return xcache_get($this->unique_id . "_" . $name);
 }
 /**
  * Veriyi döndürür
  *
  * @param string $name
  * @return bool|mixed|string
  */
 public function get($name = '')
 {
     if (false === ($var = xcache_get($name))) {
         xcache_set($name, $var = parent::get($name));
     }
     return $var;
 }
Beispiel #19
0
 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 public function get($key)
 {
     $value = xcache_get($this->prefix . $key);
     if (isset($value)) {
         return $value;
     }
 }
Beispiel #20
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
  * @access public
  */
 function read($key)
 {
     if (xcache_isset($key)) {
         return xcache_get($key);
     }
     return false;
 }
Beispiel #21
0
 public static function get($key)
 {
     global $config, $debug;
     $key = $config['cache']['prefix'] . $key;
     $data = false;
     switch ($config['cache']['enabled']) {
         case 'memcached':
             if (!self::$cache) {
                 self::init();
             }
             $data = self::$cache->get($key);
             break;
         case 'apc':
             $data = apc_fetch($key);
             break;
         case 'xcache':
             $data = xcache_get($key);
             break;
         case 'php':
             $data = isset(self::$cache[$key]) ? self::$cache[$key] : false;
             break;
     }
     // debug
     if ($data && $config['debug']) {
         $debug['cached'][] = $key;
     }
     return $data;
 }
Beispiel #22
0
 /**
  * Read the data for a particular session identifier from the SessionHandler backend.
  *
  * @param   string  $session_id  The session identifier.
  * @return  string  The session data.
  */
 public function read($session_id)
 {
     // Check if id exists
     if (!xcache_isset($this->key($session_id))) {
         return;
     }
     return (string) xcache_get($this->key($session_id));
 }
 protected function getMap()
 {
     $this->locker->get($this->id);
     if (!($map = xcache_get($this->id))) {
         $map = array();
     }
     return $map;
 }
Beispiel #24
0
 /**
  * @param \Psr\Cache\CacheItemInterface $item
  * @return mixed
  */
 protected function driverRead(CacheItemInterface $item)
 {
     $data = $this->decode(xcache_get($item->getKey()));
     if ($data === false || $data === '') {
         return null;
     }
     return $data;
 }
Beispiel #25
0
 /**
 +----------------------------------------------------------
 * 读取缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 +----------------------------------------------------------
 * @return mixed
 +----------------------------------------------------------
 */
 public function get($name)
 {
     N('cache_read', 1);
     if (xcache_isset($name)) {
         return xcache_get($name);
     }
     return false;
 }
Beispiel #26
0
 public function read($id)
 {
     $sess_id = 'sess_' . $id;
     if (!xcache_isset($sess_id)) {
         return;
     }
     return (string) xcache_get($sess_id);
 }
Beispiel #27
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);
     if ($this->exists($key)) {
         $item->setValue(xcache_get($key));
     }
     return $item;
 }
Beispiel #28
0
 /**
 +----------------------------------------------------------
 * 读取缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 +----------------------------------------------------------
 * @return mixed
 +----------------------------------------------------------
 */
 public function get($name)
 {
     $this->Q(1);
     if (xcache_isset($name)) {
         return xcache_get($name);
     }
     return false;
 }
 /**
  * Reads a cache.
  *
  * @return mixed Either the content of the cache object, or boolean `false`.
  */
 public function read()
 {
     if ($data = xcache_get($this->id)) {
         $data = $this->gzip ? gzuncompress($data) : $data;
         return unserialize($data);
     }
     return false;
 }
 /**
  * Retrieve a value from remote cache store
  *
  * @param	string		Cache unique key
  * @return	@e mixed
  */
 public function getFromCache($key)
 {
     $return_val = "";
     if (xcache_isset(md5($this->identifier . $key))) {
         $return_val = xcache_get(md5($this->identifier . $key));
     }
     return $return_val;
 }