当前位置: 首页>>代码示例>>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;未经允许,请勿转载。