本文整理汇总了PHP中Cache::decrement方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::decrement方法的具体用法?PHP Cache::decrement怎么用?PHP Cache::decrement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::decrement方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrap
public static function bootstrap()
{
// Configure Pheal
PhealConfig::getInstance()->cache = new \Pheal\Cache\FileStorage(storage_path() . '/cache/phealcache/');
PhealConfig::getInstance()->access = new \Pheal\Access\StaticCheck();
PhealConfig::getInstance()->log = new \Pheal\Log\FileStorage(storage_path() . '/logs/');
PhealConfig::getInstance()->api_customkeys = true;
PhealConfig::getInstance()->http_method = 'curl';
// Build a meaningful User-Agent for CCP should they need to contact someone
$user_agent = 'SeAT ' . \Config::get('seat.version') . ' API Fetcher at ' . \Config::get('app.url');
// Add the Url
// If the administrative_contact is set, add this to the User-Agent, else use the
// default mail_from in the settings
if (Settings::getSetting('administrative_contact') == null) {
$user_agent .= ' Install mail_from: ' . \Config::get('mail.from.name') . ' <' . \Config::get('mail.from.address') . '>';
} else {
$user_agent .= ' Administrative Contact: ' . Settings::getSetting('administrative_contact');
}
// Set the newly compiled User-Agent
PhealConfig::getInstance()->http_user_agent = $user_agent;
// Should the EVE api be determined as 'down', set the cache value for 'eve_api_down'
// with a expiration of 30 minutes. We will also decrement the current error count
// by 10 to allow for some calls to happen after the value has expired out of
// cache
if (\Cache::get('eve_api_error_count') >= \Config::get('seat.error_limit')) {
\Cache::put('eve_api_down', true, 30);
\Cache::decrement('eve_api_error_count', 10);
}
// Check if the EVE Api has been detected as 'down'.
if (\Cache::has('eve_api_down')) {
throw new Exception\APIServerDown();
}
// Disable the Laravel query log. Some of the API calls do.. a lot of queries :P
\DB::connection()->disableQueryLog();
}
示例2: Cache
function test_incr_decr()
{
$c = new Cache();
$this->assertTrue($c->set('foo', 0));
$this->assertEquals($c->increment('foo'), 1);
$this->assertEquals($c->increment('foo'), 2);
$this->assertEquals($c->increment('foo', 2), 4);
$this->assertEquals($c->decrement('foo'), 3);
$this->assertEquals($c->get('foo'), 3);
}
示例3: 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);
}
示例4: testDecrement
/**
* testDecrement method
*
* @return void
*/
public function testDecrement()
{
$this->skipIf(!function_exists('wincache_ucache_dec'), 'No wincache_ucache_dec() function, cannot test decrement().');
$result = Cache::write('test_decrement', 5, 'wincache');
$this->assertTrue($result);
$result = Cache::decrement('test_decrement', 1, 'wincache');
$this->assertEquals(4, $result);
$result = Cache::read('test_decrement', 'wincache');
$this->assertEquals(4, $result);
$result = Cache::decrement('test_decrement', 2, 'wincache');
$this->assertEquals(2, $result);
$result = Cache::read('test_decrement', 'wincache');
$this->assertEquals(2, $result);
}
示例5: testReadNonExistingConfig
/**
* Test reading from a config that is undefined.
*
* @return void
*/
public function testReadNonExistingConfig()
{
$this->assertFalse(Cache::read('key', 'totally fake'));
$this->assertFalse(Cache::write('key', 'value', 'totally fake'));
$this->assertFalse(Cache::increment('key', 1, 'totally fake'));
$this->assertFalse(Cache::decrement('key', 1, 'totally fake'));
}
示例6: testDecrement
/**
* testDecrement method
*
* @return void
*/
public function testDecrement()
{
$result = Cache::write('test_decrement', 5);
$this->assertTrue($result);
$result = Cache::decrement('test_decrement');
$this->assertEquals(4, $result);
$result = Cache::read('test_decrement');
$this->assertEquals(4, $result);
$result = Cache::decrement('test_decrement', 2);
$this->assertEquals(2, $result);
$result = Cache::read('test_decrement');
$this->assertEquals(2, $result);
}
示例7: testDecrement
/**
* testDecrement method
*
* @return void
*/
public function testDecrement()
{
$result = Cache::write('test_decrement', 5, 'memcache');
$this->assertTrue($result);
$result = Cache::decrement('test_decrement', 1, 'memcache');
$this->assertEqual(4, $result);
$result = Cache::read('test_decrement', 'memcache');
$this->assertEqual(4, $result);
$result = Cache::decrement('test_decrement', 2, 'memcache');
$this->assertEqual(2, $result);
$result = Cache::read('test_decrement', 'memcache');
$this->assertEqual(2, $result);
}
示例8: testDecrement
/**
* testDecrement method
*
* @access public
* @return void
*/
function testDecrement()
{
if ($this->skipIf(!function_exists('apc_dec'), 'No apc_dec() function, cannot test decrement() %s')) {
return;
}
$result = Cache::write('test_decrement', 5);
$this->assertTrue($result);
$result = Cache::decrement('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(4, $result);
$result = Cache::decrement('test_decrement', 2);
$this->assertEqual(2, $result);
$result = Cache::read('test_decrement');
$this->assertEqual(2, $result);
}
示例9: testDecrementCompressedKeys
/**
* test decrementing compressed keys
*
* @return void
*/
public function testDecrementCompressedKeys()
{
Cache::config('compressed_memcached', array('engine' => 'Memcached', 'duration' => '+2 seconds', 'servers' => array('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');
}
示例10: decreateCount
public function decreateCount($key, $inc = 1)
{
return $this->cache->decrement($key, $inc);
}
示例11: end
public static function end()
{
Cache::decrement(static::getKey());
}
示例12: testDecrement
/**
* testDecrement method
*
* @return void
*/
public function testDecrement()
{
$hasSupport = function_exists('apc_dec') || function_exists('apcu_dec');
$this->skipIf(!$hasSupport, 'No apc_dec()/apcu_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);
}