语法
Cache::reduction(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',100);// 自减少 1Cache::reduction('cache');var_dump(Cache::get('cache')); // 输出:99// 自减少 10Cache::reduction('cache',10);var_dump(Cache::get('cache')); // 输出:89// 自减少 0.1Cache::reduction('cache',0.1);var_dump(Cache::get('cache')); // 输出 88.9
参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| key | string | 缓存键 |
| step | int/float | 步长,默认1 |
温馨提示
除string/float/int 类型之外的参数,使用自增或者自减时会被默认转换为:0
