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