feat: 完成redis的初始化动作

This commit is contained in:
martsforever
2025-09-27 20:24:28 +08:00
parent 5eb8afcc43
commit c9c3ae91e1
8 changed files with 143 additions and 3 deletions
+14
View File
@@ -0,0 +1,14 @@
from fastapi import FastAPI
from app.utils.redis_utils import RedisClientDep
def add_redis_route(app: FastAPI):
@app.post("/redis_set/{key}")
async def redis_set(key: str, value: dict, redis_client: RedisClientDep):
await redis_client.hset(key, mapping=value)
return {"result": "success"}
@app.get("/redis_get/{key}")
async def redis_get(key: str, redis_client: RedisClientDep):
return {"result": await redis_client.hgetall(key)}