redis & listening works!!
This commit is contained in:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user