public function exists($key) { if (Armory::$armoryconfig['useApc'] == false) { return false; } return apc_exists(md5(Armory::$armoryconfig['cachePrefix'] . '_' . $key)); }
function getURL($id) { extract(shortcode_atts(array('id' => 'id'), $id)); $URL = "http://localhost/adsManagement/getAdd.php"; if ($id != "id") { $hit = apc_exists($id); if (!$hit) { $URL .= "?id=" . $id; $content = file_get_contents($URL); apc_store($id, $content); //create an index on array to store impr and store set num time to 0 if (!apc_exists("impr")) { $impr[$id] = 0; apc_store("impr", new ArrayObject($impr)); } } else { $content = apc_fetch($id); if (apc_exists("impr")) { $impr = apc_fetch("impr"); $impr[$id] = $impr[$id] + 1; apc_store("impr", new ArrayObject($impr)); } } } else { $content = file_get_contents($URL); } return $content; }
/** * 自动加载类对应的文件 * * @param string $package_name 类名 * * @return void */ public static function autoload($package_name) { $u_name = APP_NAME . 'al:' . $package_name; if (KISS::enableCache() && apc_exists($u_name)) { $filename = apc_fetch($u_name); include_once $filename; self::$_load_array[$package_name] = $filename; self::$_new_class_found = true; return; } $package_array = preg_split('/_/', $package_name); $file_array[] = join('/', $package_array); $file_array[] = strtolower($file_array[0]); array_push($package_array, 'class.' . array_pop($package_array)); $file_array[] = join('/', $package_array); $file_array[] = strtolower($file_array[2]); $path_array = explode(PATH_SEPARATOR, ini_get('include_path')); foreach ($path_array as $path) { foreach ($file_array as $file) { $filename = "{$path}/{$file}.php"; if (file_exists($filename)) { include_once $filename; if (KISS::enableCache()) { apc_store($u_name, $filename); } self::$_load_array[$package_name] = $filename; self::$_new_class_found = true; return; } } } }
public function read() { if (!apc_exists($this->key)) { return array('_global' => array()); } return apc_fetch($this->key); }
function query($type) { if (!is_null($type)) { //get parameter data $parameters = Flight::request()->query->getData(); $cacheKey = $type . json_encode($parameters); if (apc_exists($cacheKey)) { echo apc_fetch($cacheKey); } else { $url = 'http://localhost:8080/sparql'; $query_string = file_get_contents('queries/' . $type . '.txt'); foreach ($parameters as $key => $value) { $query_string = str_replace('{' . $key . '}', $value, $query_string); } //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/sparql-query")); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute post $result = curl_exec($ch); //close connection curl_close($ch); apc_store($cacheKey, $result); echo $result; } } }
/** * {@inheritdoc} * * @see \LosMiddleware\RateLimit\Storage\StorageInterface::get() */ public function get($key, $default = 0) { if (!apc_exists($this->prefix . $key)) { return $default; } return apc_fetch($this->prefix . $key); }
/** * Check if key exists. * * @param $key * @return mixed */ public function exists($key) { if (!$this->open()) { return false; } return apc_exists($key); }
public function fetch($key, $default = '') { if (!apc_exists($this->hash($key))) { return $default; } return apc_fetch($this->hash($key)); }
/** * {@inheritdoc} */ public function has($name) { if ($this->driver == self::APCU_DRIVER) { return apcu_exists($this->prefix . $name); } return apc_exists($this->prefix . $name); }
public function update($arg_key, $arg_value, $arg_expire = null) { if (apc_exists($arg_key)) { return apc_store($arg_key, $arg_value); } return false; }
/** * @param string $timeout */ public function replace($key, $value, $timeout) { if (!apc_exists($key)) { return false; } apc_store($key, $value, $timeout); }
/** * Queries a single record from the database given a primary key * @return Form */ function query() { if (defined('MO_USE_APC') && MO_USE_APC == '1') { if (function_exists("apc_exists")) { if (apc_exists(get_class($this) . "_" . $this->getId()) && $this->getId() > 0) { $fetched_successfully = false; $cached_result = apc_fetch(get_class($this) . "_" . $this->getId(), $fetched_successfully); if ($fetched_successfully) { $this->populate($cached_result); return $cached_result; } } } } // If we don't get a cached result, then query from the db $model = $this->getModel(); if (is_object($model)) { $result = $model->performQuery($this); $this->populate($result); if (defined('MO_USE_APC') && MO_USE_APC == '1') { if ($this->getId() > 0) { if (function_exists("apc_store")) { apc_store(get_class($this) . "_" . $this->getId(), $result, 14400); } } } return $result; } return $this; }
public function exists($id) { if (function_exists('apc_exists')) { return apc_exists($id); } return apc_fetch($id) === false ? false : true; }
/** * Check if an item is in the cache: */ public function contains($key) { if (!self::isEnabled()) { return false; } return apc_exists($this->cachePrefix . $key); }
public function has($key) { if ($this->apcu) { return apcu_exists((string) $key); } return apc_exists((string) $key); }
/** * @param string $key * @return boolean */ public function exists($key) { if ($retval = apc_exists($this->getCacheKey() . $key)) { return $retval; } return $this->cacheDriver->exists($this->getCacheKey() . $key); }
public static function apc_get($key) { if (apc_exists($key)) { return unserialize(apc_fetch($key)); } return null; }
/** * @return bool|string */ public function getContent() { if (function_exists('apc_fetch') && apc_exists($this->cache_entry_id)) { return apc_fetch($this->cache_entry_id); } return ''; }
/** * Get cache for $name if exist. * * @param string $name Cache id * * @return mixed data on hit, boolean false on cache not found */ public function get($name) { if (apc_exists($name)) { return apc_fetch($name); } return false; }
function driver_isExisting($keyword) { if (apc_exists($keyword)) { return true; } else { return false; } }
/** * @param $key * * @return bool */ public function exists($key) { if (function_exists('apc_exists')) { return apc_exists($this->returnKey($key)); } else { return apc_fetch($this->returnKey($key)) !== NULL; } }
function cs_cache_load($name, $ttl = 0) { $token = empty($ttl) ? $name : 'ttl_' . $name; if (apc_exists($token)) { return apc_fetch($token); } return false; }
public function __construct($key) { parent::__construct(); if (apc_exists($key)) { throw new IllegalArgumentException('Klíč již existuje, zvolte jiný.'); } $this->key = $key; }
public function replace($key, $var, $expire = 0, $options = array()) { $replaced = false; if (apc_exists($key)) { $replaced = apc_store($this->getCacheKey($key), $var, $expire); } return $replaced; }
public static function exists($key = '') { if (self::dataStoreAvailable()) { return apc_exists($key); } else { return false; } }
public function get($name, $cache_level = null) { $key = $this->_mapTags($name) . '/' . $cache_level; if (apc_exists($key)) { return array(apc_fetch($key)); } return false; }
function fetch($key) { if (extension_loaded('apc') && apc_exists("{$key}")) { return apc_fetch($key); } else { return false; } }
/** * Check if a key exists in cache. * * @param \com\mohiva\common\cache\Key $key The key for the cached value. * @return boolean True if a value for the given key exists, false otherwise. */ public function exists(Key $key) { if (function_exists('apc_exists')) { return apc_exists((string) $key); } else { return apc_fetch((string) $key) !== false; } }
/** * Connect and initialize this handler. * * @param string $name * @param bool $hard_refresh ignored * @return boolean True if successful, false on failure */ function fetch($name, $hard_refresh = false) { if (apc_exists($this->unique_id . "_" . $name)) { $data = apc_fetch($this->unique_id . "_" . $name); return unserialize($data); } return false; }
/** * Checks if APC key exists. * * @param mixed $key - A string, or an array of strings, that contain keys. * * @return mixed - Returns true if the key exists, otherwise false or if an * array was passed to keys, then an array is returned that * contains all existing keys, or an empty array if none exist. */ public static function exists($key = '') { try { return apc_exists($key); } catch (\RuntimeException $e) { throw new CacheException($e->getMessage()); } }