public static function getInstance()
{
if (self::$_instance == null) {
$config = Config::get('cache.');
$cache = new Redis($config);
self::$_instance = $cache->handler();
}
return self::$_instance;
}
private static function limitRequest($appid)
{
$key = $appid.'_a';
$value = self::getInstance()->get($key);
echo $value . PHP_EOL;
$num = self::getInstance()->incr($key);
dump($num);
$value = self::getInstance()->get($key);
echo $value . PHP_EOL;
if ($num == 1) {
//self::getInstance()->expire($key, 86400);
} else {
if ($num > 3) {
return true;
}
}
return false;
}发现每次incr后,网页上显示的值为进行的+1操作,但通过redis_cli 查看后发现每次都会多加一次? 最佳答案