本文整理汇总了PHP中Cake\Cache\Cache::decrement方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::decrement方法的具体用法?PHP Cache::decrement怎么用?PHP Cache::decrement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Cache\Cache
的用法示例。
在下文中一共展示了Cache::decrement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDecrementCompressedKeys
/**
* test decrementing compressed keys
*
* @return void
*/
public function testDecrementCompressedKeys()
{
Cache::config('compressed_memcached', ['engine' => 'Memcached', 'duration' => '+2 seconds', 'servers' => ['127.0.0.1:11211'], 'compress' => true]);
$result = Cache::write('test_decrement', 5, 'compressed_memcached');
$this->assertTrue($result);
$result = Cache::decrement('test_decrement', 1, 'compressed_memcached');
$this->assertEquals(4, $result);
$result = Cache::read('test_decrement', 'compressed_memcached');
$this->assertEquals(4, $result);
$result = Cache::decrement('test_decrement', 2, 'compressed_memcached');
$this->assertEquals(2, $result);
$result = Cache::read('test_decrement', 'compressed_memcached');
$this->assertEquals(2, $result);
Cache::delete('test_decrement', 'compressed_memcached');
}
示例2: testDecrement
/**
* testDecrement method
*
* @return void
*/
public function testDecrement()
{
Cache::delete('test_decrement', 'redis');
$result = Cache::write('test_decrement', 5, 'redis');
$this->assertTrue($result);
$result = Cache::decrement('test_decrement', 1, 'redis');
$this->assertEquals(4, $result);
$result = Cache::read('test_decrement', 'redis');
$this->assertEquals(4, $result);
$result = Cache::decrement('test_decrement', 2, 'redis');
$this->assertEquals(2, $result);
$result = Cache::read('test_decrement', 'redis');
$this->assertEquals(2, $result);
}
示例3: testDecrement
/**
* testDecrement method
*
* @return void
*/
public function testDecrement()
{
$this->skipIf(!function_exists('apc_dec'), 'No apc_dec() function, cannot test decrement().');
$result = Cache::write('test_decrement', 5, 'apc');
$this->assertTrue($result);
$result = Cache::decrement('test_decrement', 1, 'apc');
$this->assertEquals(4, $result);
$result = Cache::read('test_decrement', 'apc');
$this->assertEquals(4, $result);
$result = Cache::decrement('test_decrement', 2, 'apc');
$this->assertEquals(2, $result);
$result = Cache::read('test_decrement', 'apc');
$this->assertEquals(2, $result);
}
示例4: testDecrementNonExistingConfig
/**
* Test write from a config that is undefined.
*
* @expectedException InvalidArgumentException
* @return void
*/
public function testDecrementNonExistingConfig()
{
$this->assertFalse(Cache::decrement('key', 1, 'totally fake'));
}