feat(bot): 🎉 Create a redis client from scratch.
This commit is contained in:
@@ -9,20 +9,20 @@ async def flush():
|
||||
|
||||
import asyncpg.exceptions
|
||||
|
||||
import upstash_redis.asyncio as aredis
|
||||
import redis
|
||||
|
||||
from payphone.db import models
|
||||
|
||||
from payphone.core import constants, utils, config
|
||||
|
||||
redis = aredis.Redis(host="localhost" if config.IS_DEBUG else "redis")
|
||||
redis = redis.Redis("localhost" if config.IS_DEBUG else "redis")
|
||||
|
||||
pipe = redis.pipeline()
|
||||
|
||||
pipe.smembers(constants.CALL_IDS_TO_FLUSH)
|
||||
pipe.delete(constants.CALL_IDS_TO_FLUSH)
|
||||
|
||||
call_ids, _ = await pipe.exec()
|
||||
call_ids, _ = await pipe.execute()
|
||||
|
||||
# Redis returns bytes.
|
||||
call_ids = [int(call_id) for call_id in call_ids]
|
||||
@@ -40,7 +40,7 @@ async def flush():
|
||||
pipe.hgetall(constants.CALL_MESSAGE_CONTENTS_TEMPLATE % call_id)
|
||||
|
||||
for call_id, (messages, message_contents) in zip(
|
||||
call_ids, utils.chunks(await pipe.exec(), 2)
|
||||
call_ids, utils.chunks(await pipe.execute(), 2)
|
||||
):
|
||||
message_rows: list[models.Message] = []
|
||||
|
||||
@@ -68,7 +68,7 @@ async def flush():
|
||||
constants.CALL_IS_ACTIVE % call_id,
|
||||
)
|
||||
|
||||
await pipe.exec()
|
||||
await pipe.execute()
|
||||
|
||||
for _ in range(5):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user