Skip to content

Commit bdb88b9

Browse files
committed
Update aioredis to 2.0. (long2ice#14)
1 parent 339e5b9 commit bdb88b9

File tree

6 files changed

+214
-245
lines changed

6 files changed

+214
-245
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
## 0.1
44

5+
### 0.1.5
6+
7+
- Update aioredis to 2.0. (#14)
8+
59
### 0.1.4
610

711
- Now use `lua` script.
8-
- **Break change**: You shoud call `FastAPILimiter.init` with `await`.
12+
- **Break change**: You should call `FastAPILimiter.init` with `await`.
913

1014
```python
1115
await FastAPILimiter.init(redis)

examples/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@app.on_event("startup")
1212
async def startup():
13-
redis = await aioredis.create_redis_pool("redis://localhost", encoding="utf8")
13+
redis = await aioredis.from_url("redis://localhost", encoding="utf8")
1414
await FastAPILimiter.init(redis)
1515

1616

fastapi_limiter/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,4 @@ async def init(
7070

7171
@classmethod
7272
async def close(cls):
73-
cls.redis.close()
74-
await cls.redis.wait_closed()
73+
await cls.redis.close()

fastapi_limiter/depends.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def __call__(self, request: Request, response: Response):
4040
rate_key = await identifier(request)
4141
key = f"{FastAPILimiter.prefix}:{rate_key}:{index}"
4242
pexpire = await redis.evalsha(
43-
FastAPILimiter.lua_sha, keys=[key], args=[self.times, self.milliseconds]
43+
FastAPILimiter.lua_sha, 1, key, str(self.times), str(self.milliseconds)
4444
)
4545
if pexpire != 0:
4646
return await callback(request, response, pexpire)

0 commit comments

Comments
 (0)