redis & listening works!!

This commit is contained in:
2024-05-10 15:11:25 +03:00
parent 2a696f96c1
commit 0ebfd11851
10 changed files with 105 additions and 14 deletions

View File

@ -1,4 +1,9 @@
from typing import Annotated
from fastapi import Depends
import redis
from .db.database import SessionLocal
from .db.redis import create_redis
def get_db():
@ -7,3 +12,19 @@ def get_db():
yield db
finally:
db.close()
async def get_redis():
r = await create_redis()
try:
yield r
finally:
r.close()
async def get_pubsub(r: Annotated[redis.Redis, Depends(get_redis)]):
ps = r.pubsub()
try:
yield ps
finally:
ps.close()