本文整理汇总了PHP中apc_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP apc_exists函数的具体用法?PHP apc_exists怎么用?PHP apc_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apc_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exists
public function exists($key)
{
if (Armory::$armoryconfig['useApc'] == false) {
return false;
}
return apc_exists(md5(Armory::$armoryconfig['cachePrefix'] . '_' . $key));
}
示例2: getURL
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;
}
示例3: autoload
/**
* 自动加载类对应的文件
*
* @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;
}
}
}
}
示例4: read
public function read()
{
if (!apc_exists($this->key)) {
return array('_global' => array());
}
return apc_fetch($this->key);
}
示例5: query
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;
}
}
}
示例6: get
/**
* {@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);
}
示例7: exists
/**
* Check if key exists.
*
* @param $key
* @return mixed
*/
public function exists($key)
{
if (!$this->open()) {
return false;
}
return apc_exists($key);
}
示例8: fetch
public function fetch($key, $default = '')
{
if (!apc_exists($this->hash($key))) {
return $default;
}
return apc_fetch($this->hash($key));
}
示例9: has
/**
* {@inheritdoc}
*/
public function has($name)
{
if ($this->driver == self::APCU_DRIVER) {
return apcu_exists($this->prefix . $name);
}
return apc_exists($this->prefix . $name);
}
示例10: update
public function update($arg_key, $arg_value, $arg_expire = null)
{
if (apc_exists($arg_key)) {
return apc_store($arg_key, $arg_value);
}
return false;
}
示例11: replace
/**
* @param string $timeout
*/
public function replace($key, $value, $timeout)
{
if (!apc_exists($key)) {
return false;
}
apc_store($key, $value, $timeout);
}
示例12: query
/**
* 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;
}
示例13: exists
public function exists($id)
{
if (function_exists('apc_exists')) {
return apc_exists($id);
}
return apc_fetch($id) === false ? false : true;
}
示例14: contains
/**
* Check if an item is in the cache:
*/
public function contains($key)
{
if (!self::isEnabled()) {
return false;
}
return apc_exists($this->cachePrefix . $key);
}
示例15: has
public function has($key)
{
if ($this->apcu) {
return apcu_exists((string) $key);
}
return apc_exists((string) $key);
}