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


PHP Cache::cache方法代码示例

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


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

示例1: getCache

 static function getCache()
 {
     if (!self::$cache) {
         $config = getConfiguration('cache');
         // apply any overides to the configuration
         self::$compression = array_val($config, 'compression', self::$compression);
         self::$default_ttl = array_val($config, 'default_ttl', self::$default_ttl);
         self::$connect_timeout_msec = array_val($config, 'connect_timeout_msec', self::$connect_timeout_msec);
         self::$cache_enabled = array_val($config, 'cache_enabled', self::$cache_enabled);
         self::$local_cache_enabled = array_val($config, 'local_cache_enabled', self::$local_cache_enabled);
         // apply any overides to the debug mode
         self::$debug = array_val($config, 'debug', self::$debug);
         self::$local_cache_debug = array_val($config, 'local_cache_debug', self::$local_cache_debug);
         // build the cache object and connect the servers
         self::$cache = new Memcache();
         // get the server list out of the configuration
         foreach (array_val($config, 'servers') as $machine_name) {
             // load the configuration block for each server
             $server_config = getConfiguration('cache', $machine_name);
             // setup this servers connection
             self::$cache->addServer($server_config['host'], $server_config['port'], false, $server_config['weight'], 1, 1, false, null);
             //, self::$connect_timeout_msec);
         }
     }
     return self::$cache;
 }
开发者ID:Tapac,项目名称:hotscot,代码行数:26,代码来源:cache.php

示例2: __construct

 /**
  * Prohibit creating an object from outside
  */
 public function __construct()
 {
     phpFastCache::setup("storage", "files");
     phpFastCache::setup("path", FRONTEND_PATH . "../" . self::PATH);
     phpFastCache::setup("securityKey", "cache");
     self::$cache = new phpFastCache();
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:10,代码来源:class.Cache.php

示例3: init

 public static function init()
 {
     if (Config::config('cache') == true) {
         $config = Config::cache();
         Loader::core('CacheCarry');
         Loader::driver('caches', $config['driver']);
         self::$cache = new $config['driver']($config);
     }
 }
开发者ID:pgfeng,项目名称:GFPHP,代码行数:9,代码来源:Cache.class.php

示例4: display

 /**
  * The display method that including caching.
  *
  * @return string
  * @author Justin Palmer
  **/
 public function display()
 {
     //var_dump($this->Controller);
     //If the cache type is null just return the template.
     //Or, if the cache_type is not one of the supported cache_types
     if ($this->view_path === null || !$this->Controller->pr_do_cache || !$this->isValidCacheType()) {
         return parent::display();
     }
     //If it is a valid cache type then call the method and return the template view.
     $cached = $this->Cache->isCached();
     if ($cached !== false) {
         return $this->Cache->get();
     } else {
         $content = parent::display();
         $this->Cache->value = $content;
         $this->Cache->cache();
         return $content;
     }
 }
开发者ID:ToddBudde,项目名称:phrails,代码行数:25,代码来源:TemplateCache.php

示例5: init

 private static function init()
 {
     if (self::$cache !== null) {
         return;
     }
     global $global;
     self::$prefix = $global['name'] . '_';
     self::$cache = new Memcache();
     self::$cache->pconnect('127.0.0.1', 11211);
 }
开发者ID:cpellens,项目名称:Old-PHP-Framework,代码行数:10,代码来源:cache.php

示例6: init

 public static function init()
 {
     global $config;
     switch ($config['cache']['enabled']) {
         case 'memcached':
             self::$cache = new Memcached();
             self::$cache->addServers($config['cache']['memcached']);
             break;
         case 'php':
             self::$cache = array();
             break;
     }
 }
开发者ID:niksfish,项目名称:Tinyboard,代码行数:13,代码来源:cache.php

示例7: getCache

 /**
  * This method obtain the cache if neccesary and return it
  *
  * @access public
  * @static
  * @return array The cache of the SVG file
  * @throws Exception If the cache isn't defined an exception is throwed
  */
 public static function getCache()
 {
     self::init();
     if (file_exists(self::$filename) === false) {
         return array();
     }
     include self::$filename;
     if (isset($cache) === false) {
         throw new Exception('The cache isn\'t defined!');
     }
     self::$cache = $cache;
     return $cache;
 }
开发者ID:nojhan,项目名称:stripit,代码行数:21,代码来源:cache.class.php

示例8: Memcache

 function __construct()
 {
     $host = Config::get('db_host');
     $user = Config::get('db_user');
     $pass = Config::get('db_pass');
     $database = Config::get('db_database');
     $this->dbConnection = Database::connect($host, $user, $pass, $database);
     if (Config::get('memcache_enabled')) {
         $this->memcacheConnection = new Memcache();
         $this->memcacheConnection->pconnect(Config::get('memcache_host'), Config::get('memcache_port'));
         Cache::$cache = $this->memcacheConnection;
         Cache::$prefix = Config::get('memcache_prefix');
     }
 }
开发者ID:briancline,项目名称:spire,代码行数:14,代码来源:app.php

示例9: parse

 public function parse()
 {
     if (!file_exists($this->file)) {
         throw new NotFound("Template {$this->file} does not exist");
     }
     if ($this->load_from_cache) {
         $oCache = new Cache($this->tpl);
         if ($oCache->isValid()) {
             return $oCache->load();
         } else {
             $content = $this->readTemplate();
             $oCache->cache($content);
             return $content;
         }
     }
     return $this->readTemplate();
 }
开发者ID:BackupTheBerlios,项目名称:frameorm-svn,代码行数:17,代码来源:Template.class.php

示例10: flush

 public static function flush()
 {
     global $config;
     switch ($config['cache']['enabled']) {
         case 'memcached':
             if (!self::$cache) {
                 self::init();
             }
             return self::$cache->flush();
         case 'apc':
             return apc_clear_cache('user');
         case 'php':
             self::$cache = array();
             break;
         case 'fs':
             $files = glob('tmp/cache/*');
             foreach ($files as $file) {
                 unlink($file);
             }
             break;
         case 'redis':
             if (!self::$cache) {
                 self::init();
             }
             return self::$cache->flushDB();
     }
     return false;
 }
开发者ID:odilitime,项目名称:vichan,代码行数:28,代码来源:cache.php

示例11: clearExpired

 /**
  * Clear expired cache data via Cron module.
  */
 public static function clearExpired()
 {
     Cache::cache()->where('expires_on', '<=', time())->delete();
 }
开发者ID:simudream,项目名称:caffeine,代码行数:7,代码来源:cache.php

示例12: __construct

 /**
  * Prohibit creating an object from outside
  */
 public function __construct()
 {
     phpFastCache::setup("storage", "files");
     self::$cache = new phpFastCache();
 }
开发者ID:9x,项目名称:Runalyze,代码行数:8,代码来源:class.Cache.php

示例13: foreach

<?php

define('OC_CACHE_HOST', '127.0.0.1');
define('OC_CACHE_PORT', '11211');
define('OC_TMP', 'TMP');
define('OC_LAST_ADD_VM', 'lastAddVM');
define('OC_LAST_ADD_PM', 'lastAddPM');
define('OC_LAST_REM_VM', 'lastRemVM');
define('OC_LAST_REM_PM', 'lastRemPM');
define('OC_ND_HIGH_CONVERGENCE', true);
define('OC_STORE', 'classes');
$folders = ['src', 'src/basics', 'src/interfaces', 'src/helpers', 'src/model', 'src/rules', 'src/qualifiers', 'src/costs'];
foreach ($folders as $folder) {
    foreach (glob("{$folder}/*.php") as $filename) {
        require_once "{$filename}";
    }
}
$cache = new Memcached();
$cache->addServer(OC_CACHE_HOST, OC_CACHE_PORT);
Cache::$cache = $cache;
require_once "tests/dummyClasses.php";
Counter::$start = time() - 1;
开发者ID:arthurd2,项目名称:placements,代码行数:22,代码来源:Bootstrap.php

示例14: js

 public function js($section, $revision)
 {
     $revision = explode('.', $revision);
     $revision = (int) $revision[0];
     $file = sprintf("%s.js", $section);
     $cache = new Cache($file);
     if ($cache->isValid($revision)) {
         $content = $cache->load();
     } else {
         $content = '';
         foreach ($this->js[$section] as $style) {
             $content .= file_get_contents($style) . "\n";
         }
         $content = JSMin::minify($content);
         $cache->cache($content);
     }
     $context = Context::getInstance();
     $context->response->contentType = 'text/javascript';
     $context->response->addHeader("Expires", gmdate('D, d M Y H:i:s', time() + 365 * 24 * 3600) . ' GMT');
     return ETag::send($cache->cache_file);
 }
开发者ID:BackupTheBerlios,项目名称:frameorm-svn,代码行数:21,代码来源:Page.class.php

示例15: setEngine

 public static function setEngine(CacheEngine $cache)
 {
     self::$cache = $cache;
 }
开发者ID:google-code-backups,项目名称:gwtphp-derpc,代码行数:4,代码来源:cache.php


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