logs-redis-typings-fix

This commit is contained in:
2024-01-24 00:13:14 +03:00
parent 9b03e625f4
commit 8901ded662
7 changed files with 67 additions and 74 deletions

View File

@@ -1,6 +1,10 @@
import redis.asyncio as aredis
from settings import REDIS_URL
import logging
logger = logging.getLogger("[services.redis] ")
logger.setLevel(logging.DEBUG)
class RedisCache:
@@ -19,11 +23,13 @@ class RedisCache:
async def execute(self, command, *args, **kwargs):
if self._client:
try:
print("[redis] " + command + " " + " ".join(args))
logger.debug(command + " " + " ".join(args))
r = await self._client.execute_command(command, *args, **kwargs)
logger.debug(type(r))
logger.debug(r)
return r
except Exception as e:
print(f"[redis] error: {e}")
logger.error(e)
async def subscribe(self, *channels):
if self._client:
@@ -45,12 +51,6 @@ class RedisCache:
return
await self._client.publish(channel, data)
async def mget(self, key, *keys):
if self._client:
print(f"[redis] MGET {key} {keys}")
return await self._client.mget(key, *keys)
redis = RedisCache()
__all__ = ["redis"]