function getClassPath()
{
    static $classpath = array();
    if (!empty($classpath)) {
        return $classpath;
    }
    if (function_exists("apc_fetch")) {
        $classpath = apc_fetch("fw:root:autoload:map:1397705849");
        if ($classpath) {
            return $classpath;
        }
        $classpath = getClassMapDef();
        apc_store("fw:root:autoload:map:1397705849", $classpath);
    } else {
        if (function_exists("eaccelerator_get")) {
            $classpath = eaccelerator_get("fw:root:autoload:map:1397705849");
            if ($classpath) {
                return $classpath;
            }
            $classpath = getClassMapDef();
            eaccelerator_put("fw:root:autoload:map:1397705849", $classpath);
        } else {
            $classpath = getClassMapDef();
        }
    }
    return $classpath;
}
	/**
	 * 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) {
		$data = eaccelerator_get($key);
		if (!$data) {
			return false;
		}
		return unserialize($data);
	}
Exemple #3
0
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     \think\Cache::$writeTimes++;
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     eaccelerator_lock($name);
     if (eaccelerator_put($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $queue = eaccelerator_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);
                 // 删除缓存
                 eaccelerator_rm($key);
             }
             eaccelerator_put('__info__', $queue);
         }
         return true;
     }
     return false;
 }
Exemple #4
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)
 {
     $data = eaccelerator_get($this->unique_id . "_" . $name);
     if ($data === false) {
         return false;
     }
     return @unserialize($data);
 }
 function load($name)
 {
     $this->vars[$name] = eaccelerator_get($this->key . $name);
     if (!is_null($this->vars[$name])) {
         $this->vars[$name] = unserialize($this->vars[$name]);
     }
     return $this->vars[$name];
 }
Exemple #6
0
 public function get($key)
 {
     if (DEBUG) {
         \Lysine\logger('cache')->debug('Eaccelerator get key ' . (is_array($key) ? implode(',', $key) : $key));
     }
     $key = $this->makeKey($key);
     return eaccelerator_get($key);
 }
 public function get($key)
 {
     $val = eaccelerator_get($key);
     if (is_string($val)) {
         $val = unserialize($val);
     }
     return $val;
 }
Exemple #8
0
 /**
  * Read a key from the cache
  *
  * @param  string $key Identifier for the data
  * @return mixed  boolean FALSE if the data was not fetched from the cache, DATA on success
  */
 public function fetch($key)
 {
     $data = eaccelerator_get($key);
     if ($data == false) {
         return false;
     }
     return unserialize($data);
 }
Exemple #9
0
 protected function _get($key)
 {
     $data = eaccelerator_get($key);
     if ($data === null) {
         return self::NOT_FOUND;
     }
     return $data;
 }
 protected function getMap()
 {
     $this->locker->get($this->id);
     if (!($map = eaccelerator_get($this->id))) {
         $map = array();
     }
     return $map;
 }
 public function get($key, $tableName, $connectionResource)
 {
     $value = eaccelerator_get($this->getRealKey($tableName, $key));
     if (!empty($value)) {
         return unserialize($value);
     } else {
         return false;
     }
 }
 /**
  * Get cached data by id and group
  *
  * @param	string	$id			The cache data id
  * @param	string	$group		The cache data group
  * @param	boolean	$checkTime	True to verify cache time expiration threshold
  * @return	mixed	Boolean false on failure or a cached data string
  * @since	1.5
  */
 public function get($id, $group, $checkTime = true)
 {
     $cache_id = $this->_getCacheId($id, $group);
     $cache_content = eaccelerator_get($cache_id);
     if ($cache_content === null) {
         return false;
     }
     return $cache_content;
 }
 public function getMulti($keys)
 {
     $items = array();
     foreach ($keys as $key) {
         $value = eaccelerator_get($key);
         if ($value !== NULL) {
             $items[$key] = $value;
         }
     }
     return $items;
 }
Exemple #14
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
  */
 function do_fetch($title, &$itemlist)
 {
     $ptitle = $this->prefix . $title;
     if (($data = eaccelerator_get($ptitle)) === null) {
         // appears its not there, lets grab the data
         $itemlist[] = "'" . $this->dbobject->escape_string($title) . "'";
         return false;
     }
     $this->register($title, $data);
     return true;
 }
 /**
  * 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 = eaccelerator_get($ptitle)) === null) {
         // appears its not there, lets grab the data
         $unfetched_items[] = $title;
         return false;
     }
     $this->register($title, $data);
     return true;
 }
 /**
  * Fetch an item from the cache
  *
  * @access protected
  * @param string $var Cache key
  * @return mixed Cached data
  */
 function _read($var)
 {
     $result = eaccelerator_get($this->key_prefix . $var);
     if ($result === null) {
         return false;
     }
     // Handle serialized objects
     if (is_string($result) && strpos($result, $this->serialize_header . 'O:') === 0) {
         $result = unserialize(substr($result, strlen($this->serialize_header)));
     }
     return $result;
 }
 /**
  * load template from cache
  *
  * @access   public
  * @param	string			cache key
  * @param	integer			modification time of original template
  * @return   array|boolean	either an array containing the templates or false cache could not be loaded
  */
 function load($key, $modTime = -1)
 {
     if (!function_exists('eaccelerator_lock')) {
         return false;
     }
     $something = eaccelerator_get($key);
     if (is_null($something)) {
         return false;
     } else {
         return unserialize($something);
     }
 }
Exemple #18
0
function getRamCache($key, $depo)
{
    if ($depo == 'ram_eaccelerator') {
        $data = eaccelerator_get($key);
    }
    if ($depo == 'ram_xcache') {
        $data = xcache_get($key);
    }
    if ($depo == 'ram_memcache') {
        $memcache_obj = memcache_connect('127.0.0.1', 11211);
        $data = memcache_get($memcache_obj, $key);
    }
    return $data;
}
Exemple #19
0
 public function get($key)
 {
     $data = array();
     if (is_array($key)) {
         foreach ($key as $k) {
             $arr = eaccelerator_get($k);
             $data[$k] = $arr;
         }
         return $data;
     } else {
         $data = eaccelerator_get($key);
         return $data;
     }
 }
 /**
  * (Plug-in replacement for memcache API) Get data from the persistant cache.
  *
  * @param  mixed			Key
  * @param  ?TIME			Minimum timestamp that entries from the cache may hold (NULL: don't care)
  * @return ?mixed			The data (NULL: not found / NULL entry)
  */
 function get($key, $min_cache_date = NULL)
 {
     if (function_exists('eaccelerator_get')) {
         $data = eaccelerator_get($key);
     } elseif (function_exists('mmcache_get')) {
         $data = mmcache_get($key);
     }
     if (is_null($data)) {
         return NULL;
     }
     if (!is_null($min_cache_date) && $data[0] < $min_cache_date) {
         return NULL;
     }
     return unserialize($data[1]);
 }
Exemple #21
0
function getRamCache($key, $depo)
{
    $data = null;
    if ($depo == 'ram_eaccelerator') {
        $data = eaccelerator_get($key);
    }
    if ($depo == 'ram_xcache') {
        $data = xcache_get($key);
    }
    if ($depo == 'ram_memcache') {
        $memcache_obj = new Memcache();
        if ($memcache_obj->connect(getMemcacheHost(), getMemcachePort())) {
            $data = $memcache_obj->get($key);
            $memcache_obj->close();
        }
    }
    return $data;
}
Exemple #22
0
 /**
  * Read from cache
  *
  * @param string $name
  * @return mixed|NULL
  */
 public function read($name)
 {
     if (FALSE === $this->options->enabled) {
         return FALSE;
     }
     $this->stats->read++;
     $name = $this->prepareKey($name);
     if (NULL !== ($data = eaccelerator_get($name))) {
         if (isset($data['tags']) && is_array($data['tags'])) {
             foreach ($data['tags'] as $tag) {
                 if (NULL === $this->read('tags/' . $tag)) {
                     return NULL;
                 }
             }
         }
         return $data['value'];
     }
     return NULL;
 }
Exemple #23
0
 public function get($key)
 {
     if (($value = eaccelerator_get($key)) !== null) {
         // split the expiration time and the value
         $time = strtok($value, ':');
         $value = str_replace("{$time}:", "", $value);
         // if value has expired
         if ($_SERVER['REQUEST_TIME'] > $time) {
             // set the value with a new expiration time so others won't
             // cache-miss and trigger a "dogpile"
             $expires = $_SERVER['REQUEST_TIME'] + $this->_ttl;
             eaccelerator_put($key, "{$expires}:{$value}", 3600);
             // 1 hour
             // meanwhile, return null so the caller thinks it's expired and
             // sets it again
             $value = null;
         }
         // else value is good
         $value = unserialize($value);
     }
     return $value;
 }
 public function write($arAllVars, $baseDir, $initDir, $filename, $TTL)
 {
     $baseDirVersion = eaccelerator_get($this->sid . $baseDir);
     if ($baseDirVersion === null) {
         $baseDirVersion = md5(mt_rand());
         if (!eaccelerator_put($this->sid . $baseDir, $baseDirVersion)) {
             return;
         }
     }
     if ($initDir !== false) {
         $initDirVersion = eaccelerator_get($baseDirVersion . "|" . $initDir);
         if ($initDirVersion === null) {
             $initDirVersion = md5(mt_rand());
             if (!eaccelerator_put($baseDirVersion . "|" . $initDir, $initDirVersion)) {
                 return;
             }
         }
     } else {
         $initDirVersion = "";
     }
     $arAllVars = serialize($arAllVars);
     $this->written = strlen($arAllVars);
     eaccelerator_put($baseDirVersion . "|" . $initDirVersion . "|/" . $filename, $arAllVars, intval($TTL));
 }
 /**
  * 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 NULL === eaccelerator_get($key) ? $this->setValue($key, $value, $expire) : false;
 }
 /**
  * Read the data for a particular session identifier from the SessionHandler backend.
  *
  * @param   string  $id  The session identifier.
  *
  * @return  string  The session data.
  *
  * @since   11.1
  */
 public function read($id)
 {
     $sess_id = 'sess_' . $id;
     return (string) eaccelerator_get($sess_id);
 }
Exemple #27
0
function cache_get_data($key, $ttl = 120)
{
    global $boardurl, $sourcedir, $modSettings, $memcached;
    global $cache_hits, $cache_count, $db_show_debug;
    if (empty($modSettings['cache_enable']) && !empty($modSettings)) {
        return;
    }
    $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count] = array('k' => $key, 'd' => 'get');
        $st = microtime();
    }
    $key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . $key;
    // Okay, let's go for it memcached!
    if (function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
        // Not connected yet?
        if (empty($memcached)) {
            get_memcached_server();
        }
        if (!$memcached) {
            return;
        }
        $value = memcache_get($memcached, $key);
    } elseif (function_exists('eaccelerator_get')) {
        $value = eaccelerator_get($key);
    } elseif (function_exists('mmcache_get')) {
        $value = mmcache_get($key);
    } elseif (function_exists('apc_fetch')) {
        $value = apc_fetch($key . 'smf');
    } elseif (function_exists('output_cache_get')) {
        $value = output_cache_get($key, $ttl);
    }
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
        $cache_hits[$cache_count]['s'] = isset($value) ? strlen($value) : 0;
    }
    if (empty($value)) {
        return null;
    } else {
        return @unserialize($value);
    }
}
Exemple #28
0
 /**
  * Set expire time on each call since eAccelerator sets it on
  * cache creation.
  *
  * @param string $key        Cache key to expire.
  * @param integer $lifetime  Lifetime of the data in seconds.
  */
 protected function _setExpire($key, $lifetime)
 {
     if ($lifetime == 0) {
         // Don't expire.
         return;
     }
     $expire = eaccelerator_get($key . '_expire');
     // Set prune period.
     if ($expire + $lifetime < time()) {
         // Expired
         eaccelerator_rm($key);
         eaccelerator_rm($key . '_expire');
     }
 }
 /**
  * 读取缓存
  * @see libs/system/ICache#get($key)
  */
 public function get($key)
 {
     return \eaccelerator_get($key);
 }
Exemple #30
0
 /**
  * 
  * Gets cache entry data.
  * 
  * @param string $key The entry ID.
  * 
  * @return mixed Boolean false on failure, string on success.
  * 
  */
 public function fetch($key)
 {
     if (!$this->_active) {
         return;
     }
     // modify the key to add the prefix
     $key = $this->entry($key);
     // get from eaccelerator
     return eaccelerator_get($key);
 }