diff --git a/resolvers/load.py b/resolvers/load.py index 00cf9e2..7fb69de 100644 --- a/resolvers/load.py +++ b/resolvers/load.py @@ -55,14 +55,14 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0): cids.append(r["chat"]["id"]) for cid in cids: - # Start a transaction - tr = redis.multi_exec() - # Add the GET command to the transaction - fut = tr.get(f"chats/{cid}") - # Execute the transaction - await tr.execute() + # Start a pipeline + pipeline = redis.pipeline() + # Add the GET command to the pipeline + pipeline.get(f"chats/{cid}") + # Execute the pipeline + result = pipeline.execute() # Get the result of the GET command - c = await fut + c = result[0] print(f"got chat {c}") if c: c = json.loads(c) diff --git a/services/redis.py b/services/redis.py index bae4dec..1632a1c 100644 --- a/services/redis.py +++ b/services/redis.py @@ -52,9 +52,9 @@ class RedisCache: print(f"[redis] MGET {key} {keys}") return await self._redis.mget(key, *keys) - def multi_exec(self): - print(f"[redis] MULTI") - return self._redis.multi_exec() + def pipeline(self): + print(f"[redis] pipeline") + return self._redis.pipeline() redis = RedisCache()