feat(apikey system): api key authentication qps optimization

This commit is contained in:
谢俊男
2025-12-18 16:56:34 +08:00
parent 6d462c8f2c
commit 43a30b5a1f
2 changed files with 25 additions and 24 deletions

View File

@@ -257,7 +257,7 @@ class RateLimiterService:
key = f"rate_limit:qps:{api_key_id}"
async with self.redis.pipeline() as pipe:
pipe.incr(key)
pipe.expire(key, 1) # 1 秒过期
pipe.expire(key, 1, nx=True) # 1 秒过期
results = await pipe.execute()
current = results[0]