From 609d3c76a75b164c0d4b2927fe69379f5f95f904 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 31 Jul 2016 09:43:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Cache=E7=B1=BB=E5=92=8C?= =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Cache.php | 4 ++-- .../library/think/cache/driver/cacheTestCase.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/library/think/Cache.php b/library/think/Cache.php index 10ff01c8..c7a48789 100644 --- a/library/think/Cache.php +++ b/library/think/Cache.php @@ -118,7 +118,7 @@ class Cache * @param int $expire 有效时间 0为永久 * @return false|int */ - public function inc($name, $step = 1, $expire = null) + public static function inc($name, $step = 1, $expire = null) { self::init(); self::$writeTimes++; @@ -133,7 +133,7 @@ class Cache * @param int $expire 有效时间 0为永久 * @return false|int */ - public function dec($name, $step = 1, $expire = null) + public static function dec($name, $step = 1, $expire = null) { self::init(); self::$writeTimes++; diff --git a/tests/thinkphp/library/think/cache/driver/cacheTestCase.php b/tests/thinkphp/library/think/cache/driver/cacheTestCase.php index b280726f..3039024d 100644 --- a/tests/thinkphp/library/think/cache/driver/cacheTestCase.php +++ b/tests/thinkphp/library/think/cache/driver/cacheTestCase.php @@ -180,9 +180,16 @@ abstract class cacheTestCase extends \PHPUnit_Framework_TestCase public function testStaticCall() { - $this->assertTrue(Cache::set('a', 'a')); - $this->assertEquals('a', Cache::get('a')); + $this->assertTrue(Cache::set('a', 1)); + $this->assertEquals(1, Cache::get('a')); + $this->assertEquals(2, Cache::inc('a')); + $this->assertEquals(4, Cache::inc('a', 2)); + $this->assertEquals(4, Cache::get('a')); + $this->assertEquals(3, Cache::dec('a')); + $this->assertEquals(1, Cache::dec('a', 2)); + $this->assertEquals(1, Cache::get('a')); $this->assertNotNull(Cache::rm('a')); + $this->assertNotNull(Cache::clear()); } }