语法

  1. Cache::reduction(string $key,$setp = 1);

示例

  1. <?php
  2. require '../vendor/autoload.php';
  3. use renpengpeng\Cache;
  4. Cache::connect([
  5. 'type' => 'File',
  6. 'file' => [
  7. 'cache_dir' => realpath(__DIR__).DIRECTORY_SEPARATOR.'cache'
  8. ]
  9. ]);
  10. Cache::set('cache',100);
  11. // 自减少 1
  12. Cache::reduction('cache');
  13. var_dump(Cache::get('cache')); // 输出:99
  14. // 自减少 10
  15. Cache::reduction('cache',10);
  16. var_dump(Cache::get('cache')); // 输出:89
  17. // 自减少 0.1
  18. Cache::reduction('cache',0.1);
  19. var_dump(Cache::get('cache')); // 输出 88.9

参数说明

参数 类型 说明
key string 缓存键
step int/float 步长,默认1

温馨提示

除string/float/int 类型之外的参数,使用自增或者自减时会被默认转换为:0