race-fix4
This commit is contained in:
parent
e6579fa73c
commit
7b4524232b
|
@ -55,14 +55,14 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0):
|
||||||
cids.append(r["chat"]["id"])
|
cids.append(r["chat"]["id"])
|
||||||
|
|
||||||
for cid in cids:
|
for cid in cids:
|
||||||
# Start a transaction
|
# Start a pipeline
|
||||||
tr = redis.multi_exec()
|
pipeline = redis.pipeline()
|
||||||
# Add the GET command to the transaction
|
# Add the GET command to the pipeline
|
||||||
fut = tr.get(f"chats/{cid}")
|
pipeline.get(f"chats/{cid}")
|
||||||
# Execute the transaction
|
# Execute the pipeline
|
||||||
await tr.execute()
|
result = pipeline.execute()
|
||||||
# Get the result of the GET command
|
# Get the result of the GET command
|
||||||
c = await fut
|
c = result[0]
|
||||||
print(f"got chat {c}")
|
print(f"got chat {c}")
|
||||||
if c:
|
if c:
|
||||||
c = json.loads(c)
|
c = json.loads(c)
|
||||||
|
|
|
@ -52,9 +52,9 @@ class RedisCache:
|
||||||
print(f"[redis] MGET {key} {keys}")
|
print(f"[redis] MGET {key} {keys}")
|
||||||
return await self._redis.mget(key, *keys)
|
return await self._redis.mget(key, *keys)
|
||||||
|
|
||||||
def multi_exec(self):
|
def pipeline(self):
|
||||||
print(f"[redis] MULTI")
|
print(f"[redis] pipeline")
|
||||||
return self._redis.multi_exec()
|
return self._redis.pipeline()
|
||||||
|
|
||||||
|
|
||||||
redis = RedisCache()
|
redis = RedisCache()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user