mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de1bde39fd | ||
|
|
8490ad36f0 | ||
|
|
57fe4ce24b | ||
|
|
3dc2b53e41 | ||
|
|
2dd37b09ab | ||
|
|
0bc8c6c20e | ||
|
|
9e3c9816c5 |
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
## 0.1
|
## 0.1
|
||||||
|
|
||||||
|
### 0.1.5
|
||||||
|
|
||||||
|
- Fix setting expire for redis (#24)
|
||||||
|
- Update expire key
|
||||||
|
|
||||||
### 0.1.4
|
### 0.1.4
|
||||||
|
|
||||||
- Fix default expire for memcached. (#13)
|
- Fix default expire for memcached. (#13)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ async def index(request: Request, response: Response):
|
|||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def startup():
|
async def startup():
|
||||||
redis = await aioredis.create_redis_pool("redis://localhost", encoding="utf8")
|
redis = aioredis.from_url("redis://localhost", encoding="utf8", decode_responses=True)
|
||||||
FastAPICache.init(RedisBackend(redis), prefix="fastapi-cache")
|
FastAPICache.init(RedisBackend(redis), prefix="fastapi-cache")
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class RedisBackend(Backend):
|
|||||||
return await self.redis.get(key)
|
return await self.redis.get(key)
|
||||||
|
|
||||||
async def set(self, key: str, value: str, expire: int = None):
|
async def set(self, key: str, value: str, expire: int = None):
|
||||||
return await self.redis.set(key, value, expire=expire)
|
return await self.redis.set(key, value, ex=expire)
|
||||||
|
|
||||||
async def clear(self, namespace: str = None, key: str = None) -> int:
|
async def clear(self, namespace: str = None, key: str = None) -> int:
|
||||||
if namespace:
|
if namespace:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "fastapi-cache2"
|
name = "fastapi-cache2"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
description = "Cache for FastAPI"
|
description = "Cache for FastAPI"
|
||||||
authors = ["long2ice <long2ice@gmail.com>"]
|
authors = ["long2ice <long2ice@gmail.com>"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user