/** * 文件缓存 * * @param array $config 配置参数 * @return \phpFastCache\Core\DriverAbstract */ private function file($config = array()) { $filePath = $config['filePath']; if (!file_exists($filePath)) { Filesystem::mkdir($filePath); } //初始化缓存路径 CacheManager::setup(array("path" => isset($filePath) ? $filePath : sys_get_temp_dir())); CacheManager::CachingMethod("phpfastcache"); //初始化缓存 $InstanceCache = CacheManager::Files(); return $InstanceCache; }
public function __construct($customerKey, $environmentKey, $options = array()) { $this->_customerKey = $customerKey; $this->_environmentKey = $environmentKey; $this->_auth = "{$customerKey}:{$environmentKey}"; $this->_api = 'https://api.featureswitches.com/v1/'; if (isset($options['api'])) { $this->_api = $options['api']; } $this->_cacheTimeout = 300; if (isset($options['cache_timeout'])) { $this->_cacheTimeout = $options['cache_timeout']; } CacheManager::setup(array("path" => sys_get_temp_dir())); CacheManager::CachingMethod("phpfastcache"); $this->_cache = CacheManager::Files(); $this->_httpClient = new Client(array('base_uri' => $this->_api)); }
$rootpath = dirname($includepath); $base_theaters = array(); // Pull in configuration settings include "{$includepath}/config.php"; /* BEGIN COMMON EXECUTION CODE This section is run by every script, so it shouldn't do too much. */ // Load custom library paths for include //parseLibPath(); use phpFastCache\CacheManager; //require_once("phpfastcache/phpfastcache.php"); //phpFastCache::setup CacheManager::setup(array("path" => $cachepath, "allow_search" => true)); CacheManager::CachingMethod("phpfastcache"); $cache = CacheManager::Files(); //new phpFastCache("files"); //$cache->driver_set('path',$cachepath); //$cache->driver_set('securitykey','cache.folder'); // Connect to HLStatsX database if requested if (isset($use_hlstatsx_db)) { // If HLStatsX config exists, try that first if (file_exists($hlstatsx_config)) { require $hlstatsx_config; mysql_connect(DB_HOST, DB_USER, DB_PASS); $mysql_connection = mysql_select_db(DB_NAME); } // If no database connected (either config missing or failed to connect) use fallback if (@(!$mysql_connection)) { mysql_connect($mysql_server, $mysql_username, $mysql_password); $mysql_connection = mysql_select_db($mysql_database);
$container['logger'] = function ($c) { $settings = $c->get('settings')['logger']; $logger = new Monolog\Logger($settings['name']); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); $logger->pushHandler(new Monolog\Handler\RotatingFileHandler($settings['path'])); if (!empty($settings['token'])) { $logger->pushHandler(new Logentries\Handler\LogentriesHandler($settings['token'])); } return $logger; }; /** * Caching */ $container['cache'] = function ($c) { \phpFastCache\CacheManager::setup(["path" => $c->get('settings')['cache']['path']]); return \phpFastCache\CacheManager::Files(); }; /** * Middlewares */ require __DIR__ . '/middlewares.php'; /** * Routes */ require __DIR__ . '/routes.php'; /** * Fallback route */ require __DIR__ . '/fallback.php'; /** * Dispatch
/** * Parser constructor. * @throws ParseException */ public function __construct() { $this->cache = new Cache(CacheManager::Files(), 'routerunner_cache'); }
/** * Check the table information cache for the given table data * * @param string $database * @param string $table * @return string */ public function tableInfo($database, $table) { // use the mysql registry for this request to look up information about the database/table on this host $tableInfo = MysqlTableInfo::getInfo($this->hosts['master'], $database, $table); $MemcacheConn = null; if ($tableInfo) { return $tableInfo; } $key = current($this->hosts['master']) . "|{$database}.{$table}"; $isLocal = ServerUtility::isLocal(); // Using file cache to make thie more portable need to expose caching layer in the future CacheManager::setup(array("path" => sys_get_temp_dir())); $InstanceCache = CacheManager::Files(); // when running a local machine we want to allow schema updates to happen at anytime so no caching layer in place if ($isLocal) { $tableInfo = false; } else { $tableInfo = $InstanceCache->get($key); } if (!$tableInfo) { $tableInfo = $this->generateSchemaJson($database, $table); $InstanceCache->set($key, $tableInfo, $this->tableInfoCacheSec); MysqlTableInfo::setInfo($this->hosts['master'], $database, $table, $tableInfo); } return $tableInfo; }
<?php /** * * This file is part of phpFastCache. * * @license MIT License (MIT) * * For full copyright and license information, please see the docs/CREDITS.txt file. * * @author Khoa Bui (khoaofgod) <*****@*****.**> http://www.phpfastcache.com * @author Georges.L (Geolim4) <*****@*****.**> * */ namespace phpFastCache\plugins; use phpFastCache\CacheManager; // Setup your cronjob to run this file every // 30 mins - 60 mins to help clean up // the expired files faster require_once __DIR__ . "/../phpFastCache.php"; $setup = array("path" => "/your_path/to_clean/"); $cache = CacheManager::Files($setup); // clean up expired files cache every hour // For now only "files" drivers is supported $cache->autoCleanExpired(3600 * 1);