Async
Build and Push Docker Image / build-and-push (push) Successful in 14s

This commit is contained in:
ciomek committed 2026-09-01 18:42:43 +02:00
1 parent 8c8f98623e
commit c500c3fadf
4 files changed
+39 -26

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
import redis
import redis.asyncio as redis
from redis.backoff import ExponentialBackoff
from redis.exceptions import ConnectionError, TimeoutError
from redis.retry import Retry
+13 -6
View File
@@ -4,16 +4,23 @@ from config import settings
from loon.redis import r
def set_chunk_cache(x: int, z: int, chunk_payload):
r.setex(f'{x}:{z}', settings.redis.expire_time, str(json.dumps(chunk_payload)))
async def set_chunk_cache(x: int, z: int, chunk_payload):
await r.setex(f'{x}:{z}', settings.redis.expire_time, str(json.dumps(chunk_payload)))
def get_chunk_cache(x: int, z: int):
chunk = r.get(f'{x}:{z}')
async def get_chunk_cache(x: int, z: int):
chunk = await r.get(f'{x}:{z}')
if chunk:
return json.loads(chunk)
return None
def reset_chunk_cache(x: int, z: int):
return r.delete(f'{x}:{z}')
async def get_chunks_cache(coords):
if not coords:
return {}
vals = await r.mget([f'{x}:{z}' for x, z in coords])
return {c: json.loads(v) for c, v in zip(coords, vals) if v}
async def reset_chunk_cache(x: int, z: int):
return await r.delete(f'{x}:{z}')