/** * 递减 * @param string $key 键名 * @param int $step 递减步长 * @return int|false 递减后的值,失败返回false */ public function decr($key, $step = 1) { if ($this->driver->checkDriver()) { if (method_exists($this->driver, 'decr')) { return $this->driver->decr($key, $step); } else { if (!is_int($step)) { return false; } $value = $this->driver->get($key); if ($value !== false && !is_int($value)) { return false; } if ($this->driver->set($key, $value -= $step)) { return $value; } return false; } } if ($this->driver->isFallback() && $this->type !== self::$config['fallback']) { return $this->driver->backup()->decr($key, $step); } return false; }