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


PHP Cache::config方法代码示例

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


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

示例1: setupBeforeClass

 /**
  * test case startup
  *
  * @return void
  */
 public static function setupBeforeClass()
 {
     Cache::enable();
     Cache::config('session_test', ['engine' => 'File', 'path' => TMP . 'sessions', 'prefix' => 'session_test']);
     static::$_sessionBackup = Configure::read('Session');
     Configure::write('Session.handler.config', 'session_test');
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:12,代码来源:CacheSessionTest.php

示例2: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('Acl.classname', __NAMESPACE__ . '\\CachedDbAclTwoTest');
     $this->CachedDb = new CachedDbAclTwoTest();
     Cache::config('tests', ['engine' => 'File', 'path' => TMP, 'prefix' => 'test_']);
 }
开发者ID:edukondaluetg,项目名称:acl,代码行数:12,代码来源:CacheDbAclTest.php

示例3: initialize

 public function initialize()
 {
     parent::initialize();
     /**
      * Configure the cache for the books index page
      */
     Cache::config('exlibrisBooksIndex', ['className' => 'Apc', 'duration' => '+2 hours', 'propability' => 100, 'prefix' => 'apc_']);
 }
开发者ID:matthiasmoritz,项目名称:exlibris,代码行数:8,代码来源:BooksController.php

示例4: setUp

 /**
  * Setup method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->engine = $this->getMock('Cake\\Cache\\CacheEngine');
     $this->engine->expects($this->any())->method('init')->will($this->returnValue(true));
     Cache::config('queryCache', $this->engine);
     Cache::enable();
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:13,代码来源:QueryCacherTest.php

示例5: setUp

 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     TableRegistry::clear();
     $this->Articles = TableRegistry::get('Articles');
     Cache::config('default', ['className' => 'File', 'path' => CACHE, 'duration' => '+10 days']);
     Cache::delete('Related.attachedTables');
     Cache::delete('Related.indexedTables');
 }
开发者ID:aiphee,项目名称:cakephp-related-content,代码行数:14,代码来源:TestBehaviorsTest.php

示例6: testClearCache

 /**
  * Test clearing the cache.
  *
  * @return void
  */
 public function testClearCache()
 {
     $mock = $this->getMock('Cake\\Cache\\CacheEngine');
     $mock->expects($this->once())->method('init')->will($this->returnValue(true));
     $mock->expects($this->once())->method('clear')->will($this->returnValue(true));
     Cache::config('testing', $mock);
     $this->configRequest(['headers' => ['Accept' => 'application/json']]);
     $this->post('/debug_kit/toolbar/clear_cache', ['name' => 'testing']);
     $this->assertResponseOk();
     $this->assertResponseContains('success');
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:16,代码来源:ToolbarControllerTest.php

示例7: __construct

 /**
  * CacheStorage constructor.
  * @param array $config initial configuration
  */
 public function __construct(array $config)
 {
     $this->config($config);
     $_config = $this->config();
     $_configName = $_config['cacheConfig'];
     unset($_config['cacheConfig']);
     if (Cache::config($_configName)) {
         Cache::drop($_configName);
     }
     Cache::config($_configName, $_config);
 }
开发者ID:xavier83ar,项目名称:cakephp-cookie-auth,代码行数:15,代码来源:CacheStorage.php

示例8: setUp

 /**
  * setup method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->io = $this->getMock('Cake\\Console\\ConsoleIo');
     $this->shell = new OrmCacheShell($this->io);
     $this->cache = $this->getMock('Cake\\Cache\\CacheEngine');
     $this->cache->expects($this->any())->method('init')->will($this->returnValue(true));
     Cache::config('orm_cache', $this->cache);
     $ds = ConnectionManager::get('test');
     $ds->cacheMetadata('orm_cache');
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:16,代码来源:OrmCacheShellTest.php

示例9: startup

 /**
  * {@inheritdoc}
  */
 public function startup()
 {
     foreach (Config::get('cake_orm.datasources', []) as $name => $dataSource) {
         ConnectionManager::config($name, $dataSource);
     }
     Cache::config(Config::get('cake_orm.cache', []));
     if (!is_dir($cakeLogPath = LOG_DIR . DS . 'cake')) {
         mkdir($cakeLogPath, 0777, true);
     }
     Log::config('queries', ['className' => 'File', 'path' => LOG_DIR . DS . 'cake' . DS, 'file' => 'queries.log', 'scopes' => ['queriesLog']]);
     $this->getEventManager()->addSubscriber(new CakeORMSubscriber());
 }
开发者ID:radphp,项目名称:cake-orm-bundle,代码行数:15,代码来源:CakeOrmBundle.php

示例10: initialize

 function initialize(Container $container)
 {
     parent::initialize($container);
     $configs = $this->getConfigs();
     // 设置数据库
     foreach ($configs['datasources'] as $name => $config) {
         ConnectionManager::config($name, $config);
     }
     // 设置缓存
     foreach ($configs['cache'] as $name => $config) {
         Cache::config($name, $config);
     }
 }
开发者ID:slince,项目名称:cake-bridge,代码行数:13,代码来源:CakeBridge.php

示例11: login

 /**
  * Renders the login form.
  *
  * @return \Cake\Network\Response|null
  */
 public function login()
 {
     $this->loadModel('User.Users');
     $this->viewBuilder()->layout('login');
     if ($this->request->is('post')) {
         $loginBlocking = plugin('User')->settings('failed_login_attempts') && plugin('User')->settings('failed_login_attempts_block_seconds');
         $continue = true;
         if ($loginBlocking) {
             Cache::config('users_login', ['duration' => '+' . plugin('User')->settings('failed_login_attempts_block_seconds') . ' seconds', 'path' => CACHE, 'engine' => 'File', 'prefix' => 'qa_', 'groups' => ['acl']]);
             $cacheName = 'login_failed_' . env('REMOTE_ADDR');
             $cache = Cache::read($cacheName, 'users_login');
             if ($cache && $cache['attempts'] >= plugin('User')->settings('failed_login_attempts')) {
                 $blockTime = (int) plugin('User')->settings('failed_login_attempts_block_seconds');
                 $this->Flash->warning(__d('user', 'You have reached the maximum number of login attempts. Try again in {0} minutes.', $blockTime / 60));
                 $continue = false;
             }
         }
         if ($continue) {
             $user = $this->Auth->identify();
             if ($user) {
                 $this->Auth->setUser($user);
                 if (!empty($user['id'])) {
                     try {
                         $user = $this->Users->get($user['id']);
                         if ($user) {
                             $this->Users->touch($user, 'Users.login');
                             $this->Users->save($user);
                         }
                     } catch (\Exception $e) {
                         // invalid user
                     }
                 }
                 return $this->redirect($this->Auth->redirectUrl());
             } else {
                 if ($loginBlocking && isset($cache) && isset($cacheName)) {
                     $cacheStruct = ['attempts' => 0, 'last_attempt' => 0, 'ip' => '', 'request_log' => []];
                     $cache = array_merge($cacheStruct, $cache);
                     $cache['attempts'] += 1;
                     $cache['last_attempt'] = time();
                     $cache['ip'] = env('REMOTE_ADDR');
                     $cache['request_log'][] = ['data' => $this->request->data, 'time' => time()];
                     Cache::write($cacheName, $cache, 'users_login');
                 }
                 $this->Flash->danger(__d('user', 'Username or password is incorrect.'));
             }
         }
     }
     $user = $this->Users->newEntity();
     $this->title(__d('user', 'Login'));
     $this->set(compact('user'));
 }
开发者ID:quickapps-plugins,项目名称:user,代码行数:56,代码来源:UserSignTrait.php

示例12: initialize

 /**
  * Initialize - install cache spies.
  *
  * @return void
  */
 public function initialize()
 {
     foreach (Cache::configured() as $name) {
         $config = Cache::config($name);
         if ($config['className'] instanceof DebugEngine) {
             $instance = $config['className'];
         } else {
             Cache::drop($name);
             $instance = new DebugEngine($config);
             Cache::config($name, $instance);
         }
         $this->_instances[$name] = $instance;
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:19,代码来源:CachePanel.php

示例13: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     /* 
      * pega as configurações
      */
     $config = $e->getApplication()->getServiceManager()->get('Config');
     /* 
      * arruma a configuração do cakePHP
      */
     $config['CakePHP']['Cache']['_cake_model_']['duration'] = $config['caches']['Zend\\Cache']['options']['ttl'];
     $config['CakePHP']['Datasources']['default']['host'] = $config['db']['adapters']['Zend\\Db\\Adapter']['host'];
     $config['CakePHP']['Datasources']['default']['username'] = $config['db']['adapters']['Zend\\Db\\Adapter']['username'];
     $config['CakePHP']['Datasources']['default']['password'] = $config['db']['adapters']['Zend\\Db\\Adapter']['password'];
     $config['CakePHP']['Datasources']['default']['database'] = $config['db']['adapters']['Zend\\Db\\Adapter']['dbname'];
     /* 
      * seta o namespace padrão do CakePHP (App\Model)
      */
     foreach ($config['CakePHP']['Configure'] as $configKey => $configValue) {
         Configure::write($configKey, $configValue);
     }
     /* 
      * configura o cache do CakePHP
      */
     foreach ($config['CakePHP']['Cache'] as $configKey => $configValue) {
         $cacheDir = sprintf('%s/%s', ROOT_PATH, $configValue['path']);
         if (!is_dir($cacheDir)) {
             @mkdir($cacheDir, 0755, true);
         }
         Cache::config($configKey, $configValue);
     }
     /* 
      * configura o log do CakePHP
      */
     foreach ($config['CakePHP']['Log'] as $configKey => $configValue) {
         $logDir = sprintf('%s/%s', ROOT_PATH, $configValue['path']);
         if (!is_dir($logDir)) {
             @mkdir($logDir, 0755, true);
         }
         Log::config($configKey, $configValue);
     }
     /* 
      * setup da conexão com banco de dados no CakePHP
      */
     foreach ($config['CakePHP']['Datasources'] as $configKey => $configValue) {
         ConnectionManager::config($configKey, $configValue);
     }
 }
开发者ID:armenio,项目名称:armenio-zf2-cakephp-orm-module,代码行数:47,代码来源:Module.php

示例14: main

 /**
  * CurrentConfigShell::main()
  *
  * @return void
  */
 public function main()
 {
     $this->out('DB default:');
     try {
         $db = ConnectionManager::get('default');
         $this->out(print_r($db->config(), true));
     } catch (Exception $e) {
         $this->err($e->getMessage());
     }
     $this->out('');
     $this->out('DB test:');
     try {
         $db = ConnectionManager::get('test');
         $this->out(print_r($db->config(), true));
     } catch (Exception $e) {
         $this->err($e->getMessage());
     }
     $this->out('');
     $this->out('Cache:');
     $this->out(print_r(Cache::config('_cake_core_'), true));
 }
开发者ID:dereuromark,项目名称:cakephp-setup,代码行数:26,代码来源:CurrentConfigShell.php

示例15: testGroupClear

 /**
  * Test clearing a cache group
  *
  * @return void
  */
 public function testGroupClear()
 {
     Cache::config('memcached_groups', ['engine' => 'Memcached', 'duration' => 3600, 'groups' => ['group_a', 'group_b']]);
     $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups'));
     $this->assertTrue(Cache::clearGroup('group_a', 'memcached_groups'));
     $this->assertFalse(Cache::read('test_groups', 'memcached_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value2', 'memcached_groups'));
     $this->assertTrue(Cache::clearGroup('group_b', 'memcached_groups'));
     $this->assertFalse(Cache::read('test_groups', 'memcached_groups'));
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:15,代码来源:MemcachedEngineTest.php


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