当前位置: 首页>>代码示例>>PHP>>正文


PHP apc_store函数代码示例

本文整理汇总了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);
 }
开发者ID:e-gob,项目名称:ChileAtiende,代码行数:25,代码来源:fichas.php

示例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;
 }
开发者ID:guozqiu,项目名称:think,代码行数:35,代码来源:apc.php

示例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));
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:10,代码来源:sfAPCCache.class.php

示例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;
 }
开发者ID:superego546,项目名称:SMSGyan,代码行数:26,代码来源:binary_search.php

示例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;
        }
    }
}
开发者ID:eugenesiow,项目名称:ldanalytics-PiSmartHome,代码行数:30,代码来源:query.php

示例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);
 }
开发者ID:BGCX261,项目名称:zr4u-svn-to-git,代码行数:7,代码来源:Apc.php

示例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;
 }
开发者ID:eghojansu,项目名称:moe,代码行数:37,代码来源:Cache.php

示例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;
	
}
开发者ID:krisjanis-gross,项目名称:remote-pi,代码行数:25,代码来源:sensor_names.php

示例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;
}
开发者ID:sdgdsffdsfff,项目名称:qconf-inner,代码行数:27,代码来源:auto_load.php

示例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;
     }
 }
开发者ID:roncemer,项目名称:pfmgr2,代码行数:29,代码来源:autoload.include.php

示例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");
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:10,代码来源:Apc.php

示例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);
 }
开发者ID:nylmarcos,项目名称:estagio,代码行数:14,代码来源:ApcCachesource.php

示例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;
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:33,代码来源:UserRolePeer.php

示例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);
        }
    }
}
开发者ID:samirios1,项目名称:niter,代码行数:30,代码来源:player_p2.php

示例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);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:30,代码来源:NamespaceLoader.php


注:本文中的apc_store函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。