Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Redis teardown logic based on usage #696

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cashu/mint/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


class RedisCache:
initialized = False
expiry = settings.mint_redis_cache_ttl

def __init__(self):
Expand All @@ -27,6 +28,7 @@ async def test_connection(self):
try:
await self.redis.ping()
logger.success("Connected to Redis caching server.")
self.initialized = True
except ConnectionError as e:
logger.error("Redis connection error.")
raise e
Expand Down Expand Up @@ -64,4 +66,5 @@ async def wrapper(request: Request, payload: BaseModel):
return passthrough if not settings.mint_redis_cache_enabled else decorator

async def disconnect(self):
await self.redis.close()
if self.initialized:
await self.redis.close()
Loading