コード例 #1
0
ファイル: cache.php プロジェクト: Tapac/hotscot
 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;
 }
コード例 #2
0
ファイル: class.Cache.php プロジェクト: guancio/Runalyze
 /**
  * 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();
 }
コード例 #3
0
ファイル: Cache.class.php プロジェクト: pgfeng/GFPHP
 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);
     }
 }
コード例 #4
0
ファイル: TemplateCache.php プロジェクト: ToddBudde/phrails
 /**
  * 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;
     }
 }
コード例 #5
0
ファイル: cache.php プロジェクト: cpellens/Old-PHP-Framework
 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);
 }
コード例 #6
0
ファイル: cache.php プロジェクト: niksfish/Tinyboard
 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;
     }
 }
コード例 #7
0
ファイル: cache.class.php プロジェクト: nojhan/stripit
 /**
  * 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;
 }
コード例 #8
0
ファイル: app.php プロジェクト: briancline/spire
 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');
     }
 }
コード例 #9
0
 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();
 }
コード例 #10
0
ファイル: cache.php プロジェクト: odilitime/vichan
 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;
 }
コード例 #11
0
ファイル: cache.php プロジェクト: simudream/caffeine
 /**
  * Clear expired cache data via Cron module.
  */
 public static function clearExpired()
 {
     Cache::cache()->where('expires_on', '<=', time())->delete();
 }
コード例 #12
0
ファイル: class.Cache.php プロジェクト: 9x/Runalyze
 /**
  * Prohibit creating an object from outside
  */
 public function __construct()
 {
     phpFastCache::setup("storage", "files");
     self::$cache = new phpFastCache();
 }
コード例 #13
0
ファイル: Bootstrap.php プロジェクト: arthurd2/placements
<?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;
コード例 #14
0
 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);
 }
コード例 #15
0
 public static function setEngine(CacheEngine $cache)
 {
     self::$cache = $cache;
 }
コード例 #16
0
ファイル: class.cache.php プロジェクト: orbisnull/localcache
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         // Factory method
         switch (CACHE_TYPE) {
             case 'apc':
                 self::$cache = new APC_Cache();
                 break;
             case 'eaccelerator':
                 self::$cache = new eAccelerator_Cache();
                 break;
             case 'xcache':
                 self::$cache = new XCache_Cache();
                 break;
             case 'file':
                 self::$cache = new File_Cache();
                 break;
             case 'none':
             default:
                 self::$cache = new No_Cache();
                 break;
         }
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }