语法
Cache::increment(string $key,$setp = 1);
示例
<?phprequire '../vendor/autoload.php';use renpengpeng\Cache;Cache::connect(['type' => 'File','file' => ['cache_dir' => realpath(__DIR__).DIRECTORY_SEPARATOR.'cache']]);Cache::set('cache',1);// 自增长 1Cache::increment('cache');var_dump(Cache::get('cache')); // 输出:2// 自增长10Cache::increment('cache',10);var_dump(Cache::get('cache')); // 输出:12// 自增长 0.1Cache::increment('cache',0.1);var_dump(Cache::get('cache')); // 输出 12.1
参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| key | string | 缓存键 |
| step | int/float | 步长,默认1 |
温馨提示
除string/float/int 类型之外的参数,使用自增或者自减时会被默认转换为:0
