當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。