本文整理汇总了PHP中apc_store函数的典型用法代码示例。如果您正苦于以下问题:PHP apc_store函数的具体用法?PHP apc_store怎么用?PHP apc_store使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apc_store函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ver
function ver($id)
{
redirect(site_url('fichas/ver/' . $id), 'location', 301);
if (!($data = apc_fetch('movil_fichas_ver_data' . $id))) {
$data['theme_page'] = "d";
$data['theme_header'] = "a";
$ficha = Doctrine::getTable('Ficha')->findPublicado($id);
if ($ficha[0]->titulo) {
$data['title'] = $ficha[0]->titulo;
if ($ficha[0]->flujo) {
$data['content'] = 'movil/verflujo';
} else {
$data['content'] = 'movil/verficha';
}
$data['vista_ficha'] = true;
$data['ficha'] = $ficha[0];
if ($this->config->item('cache')) {
apc_store('movil_fichas_ver_data' . $id, $data, 60 * $this->config->item('cache'));
}
} else {
redirect('movil/ficha/error/');
}
}
$this->load->view('movil/template', $data);
}
示例2: set
/**
* 写入缓存
* @access public
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param integer $expire 有效时间(秒)
* @return bool
*/
public function set($name, $value, $expire = null)
{
if (is_null($expire)) {
$expire = $this->options['expire'];
}
$name = $this->options['prefix'] . $name;
if ($result = apc_store($name, $value, $expire)) {
if ($this->options['length'] > 0) {
// 记录缓存队列
$queue = apc_fetch('__info__');
if (!$queue) {
$queue = [];
}
if (false === array_search($name, $queue)) {
array_push($queue, $name);
}
if (count($queue) > $this->options['length']) {
// 出列
$key = array_shift($queue);
// 删除缓存
apc_delete($key);
}
apc_store('__info__', $queue);
}
}
return $result;
}
示例3: set
/**
* @see sfCache
*/
public function set($key, $data, $lifetime = null)
{
if (!$this->enabled) {
return true;
}
return apc_store($this->getOption('prefix') . $key, $data, $this->getLifetime($lifetime));
}
示例4: __construct
public function __construct($table, $field, $min, $condition = "", $cacheName = "")
{
if (empty($cacheName) || $cacheName == "") {
$cacheName = $table;
}
$this->array = apc_fetch($cacheName, $success);
if (!$success) {
echo "{$table} FROM DATABASE";
if (!empty($condition)) {
echo $query = "select {$field} from {$table} where {$condition} order by {$field}";
} else {
echo $query = "select {$field} from {$table} order by {$field}";
}
$result = mysql_query($query) or trigger_error(mysql_error(), E_USER_ERROR);
if (mysql_num_rows($result)) {
echo "Sucess";
$this->array = array();
while ($row = mysql_fetch_array($result)) {
$this->array[] = strtolower($row[$field]);
}
apc_store($cacheName, $this->array);
}
}
$this->count = count($this->array);
$this->min = $min;
}
示例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: set
public function set($id, $data, array $tags = NULL, $lifetime)
{
if (!empty($tags)) {
throw new LemonRuntimeException('Cache: tags are unsupported by the APC driver', 500);
}
return apc_store($id, $data, $lifetime);
}
示例7: set
/**
* Store value in cache
* @return mixed|FALSE
* @param $key string
* @param $val mixed
* @param $ttl int
**/
function set($key, $val, $ttl = 0)
{
$fw = Base::instance();
if (!$this->dsn) {
return TRUE;
}
$ndx = $this->prefix . '.' . $key;
$time = microtime(TRUE);
if ($cached = $this->exists($key)) {
list($time, $ttl) = $cached;
}
$data = $fw->serialize(array($val, $time, $ttl));
$parts = explode('=', $this->dsn, 2);
switch ($parts[0]) {
case 'apc':
case 'apcu':
return apc_store($ndx, $data, $ttl);
case 'redis':
return $this->ref->set($ndx, $data, array('ex' => $ttl));
case 'memcache':
return memcache_set($this->ref, $ndx, $data, 0, $ttl);
case 'wincache':
return wincache_ucache_set($ndx, $data, $ttl);
case 'xcache':
return xcache_set($ndx, $data, $ttl);
case 'folder':
return $fw->write($parts[1] . $ndx, $data);
}
return FALSE;
}
示例8: get_sensor_name_list
function get_sensor_name_list () {
$sensor_list = apc_fetch('sensor_list');
//var_dump($sensor_list);
if (!$sensor_list) // if not available in APC then read the list from DB, then save the list in APC
{
//echo "must read sesnor list from db";
$static_db = open_static_data_db(true);
$results = $static_db->query('SELECT * FROM sensor_names;');
while ($row = $results->fetchArray()) {
$sensor_id = $row['id'];
$sensor_name = $row['sensor_name'];
$sensor_list[$sensor_id] = $sensor_name;
//var_dump($sensor_list);
// save the sensor list in APC
}
$static_db->close();
apc_store('sensor_list', $sensor_list);
}
return $sensor_list;
}
示例9: getClassPath
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;
}
示例10: __jax__loadClass
function __jax__loadClass($class_name)
{
global $__CLASS_AUTO_LOAD_CLASS_PATHS, $__CLASS_AUTO_LOAD_PATH_CACHE_TIMEOUT;
$cacheKey = 'classAutoload:' . sha1($_SERVER['DOCUMENT_ROOT']) . ':' . $class_name;
if (function_exists('apc_fetch')) {
$path = @apc_fetch($cacheKey, $success);
} else {
$path = null;
$success = false;
}
if (!$success) {
foreach ($__CLASS_AUTO_LOAD_CLASS_PATHS as $dir) {
$path = __jax__classAutoloadFindClassFile($class_name, $dir);
if ($path !== false) {
if (function_exists('apc_add')) {
@apc_add($cacheKey, $path, $__CLASS_AUTO_LOAD_PATH_CACHE_TIMEOUT);
} else {
if (function_exists('apc_store')) {
@apc_store($cacheKey, $path, $__CLASS_AUTO_LOAD_PATH_CACHE_TIMEOUT);
}
}
break;
}
}
}
if ($path !== false) {
include $path;
}
}
示例11: set
/**
* @inheritDoc
*/
public function set($key, $value)
{
$rc = apc_store($key, array('time' => time(), 'data' => $value));
if ($rc == false) {
throw new Google_Cache_Exception("Couldn't store data");
}
}
示例12: write
/**
* Escreve dados no cache
* @param string $key chave em que será gravado o cache
* @param mixed $data dados a serem gravados
* @param int $time tempo, em minutos, que o cache existirá
* @return boolean retorna true se o cache for gravado com sucesso, no contrário, retorna false
*/
public function write($key, $data, $time = 1)
{
$file = array();
$file['time'] = time() + $time * minute;
$file['data'] = $data;
return apc_store(md5($key), $file);
}
示例13: getIdByStrId
public static function getIdByStrId($strId)
{
// try to get strId to id mapping form cache
$cacheKey = 'UserRolePeer_role_str_id_' . $strId;
if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
$id = apc_fetch($cacheKey);
// try to fetch from cache
if ($id) {
KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - fetched from cache");
return $id;
}
}
// not found in cache - get from database
$c = new Criteria();
$c->addSelectColumn(UserRolePeer::ID);
$c->addAnd(UserRolePeer::STR_ID, $strId, Criteria::EQUAL);
$c->setLimit(1);
$stmt = UserRolePeer::doSelectStmt($c);
$id = $stmt->fetch(PDO::FETCH_COLUMN);
if ($id) {
// store the found id in cache for later use
if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
$success = apc_store($cacheKey, $id, kConf::get('apc_cache_ttl'));
if ($success) {
KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - stored in cache");
}
}
}
if (!$id) {
KalturaLog::log("UserRole with str_id [{$strId}] not found in DB!");
}
return $id;
}
示例14: loguear
function loguear($is_cache)
{
global $link, $original_req, $log_active;
if ($log_active) {
$cache_key2 = "IPsLog";
$cache = apc_fetch($cache_key2, $susses);
$link_log = $original_req;
if ($original_req != $link) {
$link_log = $original_req . " -> " . $link;
}
if ($is_cache) {
$link_log = "(from cache)" . $link_log;
}
$add = "(IP: " . $_SERVER['REMOTE_ADDR'] . ") " . $link_log . "\n [header: " . getallheaders() . "]";
if ($susses) {
apc_store($cache_key2, $cache . "\n\n" . $add, 1800);
} else {
apc_store($cache_key2, $add, 1800);
}
$cache_key2 = "IPsLogExcel";
$cache = apc_fetch($cache_key2, $susses);
$add = $_SERVER['REMOTE_ADDR'] . "\t" . $original_req . "\t" . $link . "\t" . $_SERVER['HTTP_REFERER'] . "\n";
if ($susses) {
apc_store($cache_key2, $cache . $add, 1800);
} else {
$add = "IP\tOriginal request\tRequest Procesado\tReferer\n" . $add;
apc_store($cache_key2, $add, 1800);
}
}
}
示例15: loadClass
/**
* @param string $ClassName
*
* @return bool
*/
public function loadClass($ClassName)
{
if ($this->checkExists($ClassName)) {
return true;
}
if (function_exists('apc_fetch')) {
$Hash = sha1($this->Namespace . $this->Path . $this->Separator . $this->Extension . $this->Prefix);
// @codeCoverageIgnoreStart
if (false === ($Result = apc_fetch($Hash . '#' . $ClassName))) {
$Result = $this->checkCanLoadClass($ClassName);
apc_store($Hash . '#' . $ClassName, $Result ? 1 : 0);
}
if (!$Result) {
return false;
}
} else {
// @codeCoverageIgnoreEnd
if (!$this->checkCanLoadClass($ClassName)) {
return false;
}
}
/** @noinspection PhpIncludeInspection */
require $this->Path . DIRECTORY_SEPARATOR . trim(str_replace(array($this->Prefix . $this->Separator, $this->Separator), array('', DIRECTORY_SEPARATOR), $ClassName), DIRECTORY_SEPARATOR) . $this->Extension;
return $this->checkExists($ClassName);
}