示例#1
0
 /**
  * Create and return the instance of phpFastCache\CacheManager 
  *
  * @return object	the instance of the Cache Manager if cache enabled
  *								in the configuration file (config/cache.php), null
  *								if disabled
  *
  * @static
  * @see Cache::clean()
  * @access public
  * @since Method available since Release 0.1.0
  */
 static function init()
 {
     if (self::$config === null) {
         self::$config = Config::get('cache');
     }
     if (self::$config['enabled'] === true) {
         CacheManager::setup(self::$config['settings']);
         if (self::$CacheManager === null) {
             self::$CacheManager = CacheManager::getInstance();
         }
         return self::$CacheManager;
     } else {
         return null;
     }
 }
 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));
 }
$includepath = realpath(dirname(__FILE__));
// rootpath is the insurgency-tools root
$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)) {
示例#4
0
 /**
  * redis缓存
  *
  * @param array $config 配置参数
  * @return \phpFastCache\Core\DriverAbstract
  */
 private function redis($config = array())
 {
     CacheManager::setup(array('redis' => array($config)));
     $InstanceCache = CacheManager::Redis();
     return $InstanceCache;
 }
示例#5
0
 */
$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';
/**
示例#6
0
文件: Object.php 项目: phpffcms/ffcms
        $handler = new PdoSessionHandler($pdo, ['db_table' => App::$Properties->get('database')['prefix'] . 'sessions']);
    } catch (Exception $e) {
        $handler = new NativeFileSessionHandler(root . '/Private/Sessions');
    }
    $storage = new NativeSessionStorage(['cookie_lifetime' => 86400, 'gc_maxlifetime' => 86400, 'cookie_httponly' => '1'], $handler);
    return new Session($storage);
}, 'User' => function () {
    return new Apps\ActiveRecord\User();
}, 'Mailer' => function () {
    $swiftTransport = Swift_MailTransport::newInstance();
    return Swift_Mailer::newInstance($swiftTransport);
}, 'Captcha' => function () {
    return new Extend\Core\Captcha\Gregwar();
}, 'Cache' => function () {
    // initialize cache manager. You can use redis, memcache or anything else. Look at: phpfastcache.com
    CacheManager::setup(['storage' => 'files', 'path' => root . '/Private/Cache']);
    return CacheManager::getInstance('files');
}, '_hybridauth' => function () {
    /** Uncomment code below to enable social oauth
         $instance = new Hybrid_Auth([
            'base_url' => App::$Alias->scriptUrl . '/api/user/endpoint?lang=en',
            'providers' => [
                'Twitter' => [
                    'enabled' => true,
                    'keys' => [
                        'key' => 'my_app_key',
                        'secret' => 'my_app_secret'
                    ],
                    'scope' => 'email'
                ],
                'Github' => [
示例#7
0
 /**
  * CacheItemPool constructor.
  *
  * @param array  $config
  * @param string $method
  */
 public function __construct(array $config, $method = 'normal')
 {
     CacheManager::setup($config);
     CacheManager::CachingMethod($method);
     $this->_cache = CacheManager::getInstance();
 }
示例#8
0
 /**
  * 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;
 }