當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cache::increment方法代碼示例

本文整理匯總了PHP中Cake\Cache\Cache::increment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cache::increment方法的具體用法?PHP Cache::increment怎麽用?PHP Cache::increment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Cache\Cache的用法示例。


在下文中一共展示了Cache::increment方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _touch

 protected function _touch(Request $request)
 {
     $key = $this->config('identifier');
     if (is_callable($key)) {
         $key = $key($request);
     }
     return Cache::increment($key, static::$cacheConfig);
 }
開發者ID:Adnan0703,項目名稱:Throttle,代碼行數:8,代碼來源:ThrottleFilter.php

示例2: testGroupReadWrite

 /**
  * Tests that configuring groups for stored keys return the correct values when read/written
  * Shows that altering the group value is equivalent to deleting all keys under the same
  * group
  *
  * @return void
  */
 public function testGroupReadWrite()
 {
     Cache::config('memcached_groups', ['engine' => 'Memcached', 'duration' => 3600, 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_']);
     Cache::config('memcached_helper', ['engine' => 'Memcached', 'duration' => 3600, 'prefix' => 'test_']);
     $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups'));
     $this->assertEquals('value', Cache::read('test_groups', 'memcached_groups'));
     Cache::increment('group_a', 1, 'memcached_helper');
     $this->assertFalse(Cache::read('test_groups', 'memcached_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value2', 'memcached_groups'));
     $this->assertEquals('value2', Cache::read('test_groups', 'memcached_groups'));
     Cache::increment('group_b', 1, 'memcached_helper');
     $this->assertFalse(Cache::read('test_groups', 'memcached_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value3', 'memcached_groups'));
     $this->assertEquals('value3', Cache::read('test_groups', 'memcached_groups'));
 }
開發者ID:KarimaLadhani,項目名稱:cakephp,代碼行數:22,代碼來源:MemcachedEngineTest.php

示例3: testIncrement

 /**
  * testIncrement method
  *
  * @return void
  */
 public function testIncrement()
 {
     $this->skipIf(!function_exists('apc_inc'), 'No apc_inc() function, cannot test increment().');
     $result = Cache::write('test_increment', 5, 'apc');
     $this->assertTrue($result);
     $result = Cache::increment('test_increment', 1, 'apc');
     $this->assertEquals(6, $result);
     $result = Cache::read('test_increment', 'apc');
     $this->assertEquals(6, $result);
     $result = Cache::increment('test_increment', 2, 'apc');
     $this->assertEquals(8, $result);
     $result = Cache::read('test_increment', 'apc');
     $this->assertEquals(8, $result);
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:19,代碼來源:ApcEngineTest.php

示例4: testIncrementNonExistingConfig

 /**
  * Test write from a config that is undefined.
  *
  * @expectedException InvalidArgumentException
  * @return void
  */
 public function testIncrementNonExistingConfig()
 {
     $this->assertFalse(Cache::increment('key', 1, 'totally fake'));
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:10,代碼來源:CacheTest.php

示例5: testIncrement

 /**
  * testIncrement method
  *
  * @return void
  */
 public function testIncrement()
 {
     $result = Cache::write('test_increment', 5, 'xcache');
     $this->assertTrue($result);
     $result = Cache::increment('test_increment', 'xcache');
     $this->assertEquals(6, $result);
     $result = Cache::read('test_increment', 'xcache');
     $this->assertEquals(6, $result);
     $result = Cache::increment('test_increment', 2, 'xcache');
     $this->assertEquals(8, $result);
     $result = Cache::read('test_increment', 'xcache');
     $this->assertEquals(8, $result);
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:18,代碼來源:XcacheEngineTest.php

示例6: _touch

 /**
  * Atomically updates cache using default CakePHP increment offset 1.
  *
  * Please note that the cache key needs to be initialized to prevent
  * increment() failing on 0. A separate cache key is created to store
  * the interval expiration time in epoch.
  *
  * @return Cake\Cache\Cache
  */
 protected function _touch()
 {
     if (Cache::read($this->_identifier, static::$cacheConfig) === false) {
         Cache::write($this->_identifier, 0, static::$cacheConfig);
         Cache::write($this->_getCacheExpirationKey(), strtotime($this->config('interval'), time()), static::$cacheConfig);
     }
     return Cache::increment($this->_identifier, 1, static::$cacheConfig);
 }
開發者ID:nielin,項目名稱:Throttle,代碼行數:17,代碼來源:ThrottleFilter.php


注:本文中的Cake\Cache\Cache::increment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。