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()); } }