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


PHP Cache::factory方法代码示例

本文整理汇总了PHP中Cache::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::factory方法的具体用法?PHP Cache::factory怎么用?PHP Cache::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


在下文中一共展示了Cache::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 /**
  * Returns a singleton instance
  *
  * @return Cache_Redis
  * @access public
  */
 public static function &getInstance()
 {
     if (!isset(self::$_instances[0]) || !self::$_instances[0]) {
         self::$_instances[0] = Cache::factory('redis');
     }
     return self::$_instances[0];
 }
开发者ID:ahmatjan,项目名称:Scene-Editor-for-mobile,代码行数:13,代码来源:Redis.php

示例2: action_cache

 /**
  * 缓存
  *+----
  */
 public function action_cache()
 {
     $cache = Cache::factory('file');
     //获取一个文件缓存实例
     //$cache->set('name', time(), 60); //设置有效期60s
     echo $cache->get('name');
     //$cache->del('name');
 }
开发者ID:adawongframework,项目名称:project,代码行数:12,代码来源:Welcome.php

示例3: run

 public function run(FilterChain $oFilterChain)
 {
     $aDb = Core::app()->config()->getCache();
     foreach ($aDb as $k => $val) {
         Manager::getInstance()->getCache()->add(Cache::factory($val['Driver'], $val['Params']), $k);
     }
     $oFilterChain->next();
 }
开发者ID:ruxon,项目名称:framework,代码行数:8,代码来源:CacheFilter.class.php

示例4: __construct

 /**
  * Contrutor da classe
  * @param	string	$url	url acessada pelo usuário
  */
 public function __construct($url)
 {
     define('CACHE_TIME', 60);
     $cache_config = Config::get('cache');
     if ($cache_config['page']) {
         $cache = Cache::factory();
         if ($cache->has(URL)) {
             $data = $cache->read(URL);
             exit($data);
         }
     }
     $registry = Registry::getInstance();
     $this->args = $this->args($url);
     //I18n
     define('lang', $this->args['lang']);
     define('LANG', $this->args['lang']);
     $i18n = I18n::getInstance();
     $i18n->setLang(LANG);
     $registry->set('I18n', $i18n);
     function __($string, $format = null)
     {
         return I18n::getInstance()->get($string, $format);
     }
     function _e($string, $format = null)
     {
         echo I18n::getInstance()->get($string, $format);
     }
     define('controller', Inflector::camelize($this->args['controller']) . 'Controller');
     define('action', str_replace('-', '_', $this->args['action']));
     define('CONTROLLER', Inflector::camelize($this->args['controller']) . 'Controller');
     define('ACTION', str_replace('-', '_', $this->args['action']));
     try {
         header('Content-type: text/html; charset=' . Config::get('charset'));
         Import::core('Controller', 'Template', 'Annotation');
         Import::controller(CONTROLLER);
         $this->controller();
         $this->auth();
         $tpl = new Template();
         $registry->set('Template', $tpl);
         $tpl->render($this->args);
         if ($cache_config['page']) {
             $cache = Cache::factory();
             $data = ob_get_clean();
             $cache->write(URL, $data, $cache_config['time']);
         }
         Debug::show();
     } catch (PageNotFoundException $e) {
         header('HTTP/1.1 404 Not Found');
         $this->loadError($e);
         exit;
     } catch (Exception $e) {
         header('HTTP/1.1 500 Internal Server Error');
         $this->loadError($e);
     }
 }
开发者ID:nylmarcos,项目名称:estagio,代码行数:59,代码来源:App.php

示例5: array

 /**
  * @param string имя драйвера кеша
  * @param mixed false или array()
  * @return Cache объект
  */
 static function &singleton($driver = 'apc', $init = true)
 {
     static $instances = array();
     $signature = serialize(array($driver, $init));
     if (empty($instances[$signature])) {
         $instances[$signature] = Cache::factory($driver);
         if ($init !== false) {
             $instances[$signature]->init($init);
         }
     }
     return $instances[$signature];
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:17,代码来源:cache.php

示例6: load_domain

 static function load_domain($domain)
 {
     if (!isset(self::$items[$domain])) {
         $cache = Cache::factory();
         $locale = self::$locale;
         $cache_key = "i18n/{$locale}/{$domain}";
         $lang = Config::get('debug.i18n_nocache') ? false : $cache->get($cache_key);
         if ($lang === false) {
             $lang = array();
             foreach (array_reverse(Core::file_paths(I18N_BASE . $locale . EXT, $domain)) as $path) {
                 !file_exists($path) or @(include $path);
             }
             $cache->set($cache_key, $lang);
         }
         self::$items[$domain] = (array) $lang;
     }
 }
开发者ID:pihizi,项目名称:qf,代码行数:17,代码来源:i18n.php

示例7: getProperties

        $key = 'Trilado.Annotation.Property.' . $this->classname . '->' . $property;
        $cache = Cache::factory();
        if (Debug::enabled() && $cache->has($key)) {
            return $cache->read($key);
        } else {
            $reflection = new ReflectionProperty($this->classname, $property);
            $comment = $reflection->getDocComment();
            $annotation = $this->extractAnnotation($comment);
            $cache->write($key, $annotation, CACHE_TIME);
            return $annotation;
        }
    }
    /**
	 * Pega a anotação todas as propriedades da classe
	 * @return	array	lista com instâncias de sdtClass
	 */
    public function getProperties()
    {
开发者ID:nylmarcos,项目名称:estagio,代码行数:18,代码来源:Annotation.php

示例8: parse

 function parse()
 {
     if (!$this->_is_parsed) {
         $cache_data = false;
         $cache_key = Misc::key('Q:', $this->selector);
         $cache = Cache::factory();
         if (!Config::get('debug.Q_nocache', FALSE)) {
             $cache_data = $cache->get($cache_key);
         }
         if (false === $cache_data) {
             $query = $this->parse_selector();
             $cache_data = array('name' => $query->name, 'SQL' => $query->SQL, 'count_SQL' => $query->count_SQL, 'sum_SQL' => $query->sum_SQL);
             if ($cache) {
                 $cache->set($cache_key, $cache_data);
             }
         }
         $this->SQL = $cache_data['SQL'];
         $this->count_SQL = $cache_data['count_SQL'];
         $this->sum_SQL = $cache_data['sum_SQL'];
         $this->_is_parsed = TRUE;
         $this->name = $cache_data['name'];
     }
 }
开发者ID:pihizi,项目名称:qf,代码行数:23,代码来源:q.php

示例9: load

 /**
  * Carrega um arquivo de tradução pegando as mensagens e traduções e joga em array retornando-o
  * @param	string	$lang		nome do arquivo
  * @throws	TriladoException	disparada caso o arquivo não exista ou o conteúdo esteja vazio
  * @return	array				retorna um array com as mensagens de tradução, sendo as chaves o MD5 da mensagem original
  */
 private function load($lang)
 {
     $key = 'Trilado.I18n.' . $lang;
     $cache = Cache::factory();
     if ($cache->has($key)) {
         return $cache->read($key);
     }
     $file_path = ROOT . 'app/i18n/' . $lang . '.lang';
     if (!file_exists($file_path)) {
         throw new FileNotFoundException($file_path);
     }
     $lines = file($file_path);
     if (!count($lines)) {
         throw new TriladoException('Arquivo "' . $file_path . '" está vazio');
     }
     $key = false;
     $result = array();
     foreach ($lines as $line) {
         $line = trim($line);
         if (preg_match('@^(msgid|msgstr)@', $line)) {
             if (preg_match('/^msgid "(.+)"/', $line, $match)) {
                 $key = md5($match[1]);
             } elseif (preg_match('/^msgstr "(.+)"/', $line, $match)) {
                 if (!$key) {
                     throw new TriladoException('Erro de sintax no arquivo "' . $file_path . '" na linha "' . $match[1] . '"');
                 }
                 $result[$key] = $match[1];
                 $key = false;
             }
         }
     }
     foreach ($this->hook as $hook) {
         $result = $hook->load($result);
     }
     $cache->write($key, $result, CACHE_TIME);
     return $result;
 }
开发者ID:nylmarcos,项目名称:estagio,代码行数:43,代码来源:I18n.php

示例10: getCache

 public function getCache($which)
 {
     // do we already have the cache object in the Registry ?
     if (Registry::isRegistered('cache_' . $which)) {
         return Registry::get('cache_' . $which);
     } else {
         // get the config for our cache object
         $config = Registry::get('config');
         if (isset($config->cache->{$which}->handler)) {
             $cache = Cache::factory($config->cache->{$which}->handler, isset($config->cache->{$which}->params) ? $config->cache->{$which}->params : array(), isset($config->cache->{$which}->lifetime) ? $config->cache->{$which}->lifetime : Cache::DEFAULT_LIFETIME);
             return $cache;
         } else {
             throw new Exception('The cache handler "' . $which . '" is not set in config file');
         }
     }
 }
开发者ID:atlantis3001,项目名称:nofussframework,代码行数:16,代码来源:Front.php

示例11: define

define('CACHE_EXIT_ON_ERROR', true);
error_reporting(E_ALL);
// number of iterations
define('TEST_ITERATIONS', 100);
// how many reads should be performed per each set/update
define('TEST_READS', 1);
require "Benchmark/Timer.php";
require 'testCases/Cache.php';
$t = new Benchmark_Timer();
$t->start();
$aTests = array(25, 50, 75, 100);
$t->setMarker('Script init');
foreach ($aTests as $concurrency) {
    $oTest = Cache::factory(array('type' => 'memcached', 'host' => '127.0.0.1', 'port' => 11211));
    test_update($oTest, $concurrency, $t, 'MEMCACHED ');
    $oTest = Cache::factory(array('type' => 'sharedance', 'host' => 'localhost'));
    test_update($oTest, $concurrency, $t, 'SHAREDANCE');
}
$t->stop();
$t->display();
exit;
function test_update($oTest, $concurrency, $t, $text)
{
    $oTest->disconnect();
    $oTest->invalidateAll();
    $oTest->init($concurrency, TEST_ITERATIONS);
    for ($c = 0; $c < $concurrency; $c++) {
        mt_srand(1000 + $c);
        $pid = pcntl_fork();
        if ($pid == 0) {
            $oTest->connect();
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:31,代码来源:run.php

示例12: __construct

 /**
  * Конструктор
  */
 public function __construct($config)
 {
     parent::__construct($config);
     hook('preload', array($this, 'hookPreload'));
     $this->object(Cache::factory('normal', config('cache')));
 }
开发者ID:brussens,项目名称:cogear2,代码行数:9,代码来源:Gear.php

示例13: loadDefaultLibs

 /**
  * Loads the default most commonly used libraries for the framework
  *
  * @return object
  */
 public function loadDefaultLibs()
 {
     $config = Registry::get('config');
     foreach ($this->defaultLibs as $library) {
         if ($library == 'cache') {
             try {
                 $cache = Cache::factory($config->get('cache/type'));
             } catch (Config_KeyNoExist $e) {
                 // Revert to file based caching.
                 $cache = Cache::factory('file');
             }
             try {
                 $cache->ttl($config->get('cache/ttl'));
             } catch (Exception $e) {
             }
         } else {
             if ($library == 'i18n') {
                 try {
                     I18n::factory($config->get('locale/engine'));
                 } catch (Config_KeyNoExist $e) {
                     I18n::factory('failsafe');
                 }
             } else {
                 $this->loadLib($library);
             }
         }
     }
     return $this;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:34,代码来源:zula.php

示例14: autoload

 /**
  * Função que importa classes automaticamente, baseado nos diretórios 
  * registrados pelo método Import::register($dir).
  * @param	string	$class	Nome da classe a ser carregada.
  * @return	void
  */
 public static function autoload($class)
 {
     $key = 'Trilado.Import.Files';
     $cache = Cache::factory();
     if ($cache->has($key)) {
         $files = $cache->read($key);
         if (isset($files[$class])) {
             require_once $files[$class];
             return;
         }
     }
     foreach (self::$directories as $dir) {
         $file = ROOT . $dir . $class . '.php';
         if (file_exists($file)) {
             require_once $file;
             $files = $cache->read($key);
             if ($files === false) {
                 $files = array();
             }
             $files[$class] = $file;
             $cache->write($key, $files, CACHE_TIME);
             return;
         }
     }
 }
开发者ID:nylmarcos,项目名称:estagio,代码行数:31,代码来源:Import.php

示例15: getUser

 /**
  * 获取用户信息
  *
  * @param int $userid 用户 id
  * @param array $column 列
  */
 public static function getUser($userid, $column = array())
 {
     $ret = array('id', 'userid', 'pwd', 'kid', 'mobile', 'email', 'status', 'regtime', 'regip', 'logintime', 'loginip', 'login_nums');
     $ret = array_merge($ret, $column);
     /*$select = Da_Wrapper::select()
     			->table(self::DB_TABLE_USER)
     			->columns($ret)
     			->where('id', $userid);
     
     		return $select->getRow();*/
     $cache = Cache::factory();
     $key = 'user_' . $userid;
     $cacheData = $cache->get($key);
     if (false == $cacheData) {
         $select = Da_Wrapper::select()->table(self::DB_TABLE_USER)->where('id', $userid)->getRow();
         $cache->set($key, $select);
     } else {
         $select = $cacheData;
     }
     foreach ($select as $key => $value) {
         if (false == in_array($key, $ret)) {
             unset($select[$key]);
         }
     }
     return $select;
 }
开发者ID:ahmatjan,项目名称:Scene-Editor-for-mobile,代码行数:32,代码来源:User.php


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