speed up loading and saving to redis that the move request are getting a answer when switching workers, strip data that neats to get recomuted every turn
Build and Push Docker Container / build-and-push (push) Successful in 4m49s

This commit is contained in:
2026-04-07 12:13:11 +02:00
parent f479541c04
commit f6e19e18e6
6 changed files with 58 additions and 7 deletions
@@ -1,5 +1,5 @@
from typing import TYPE_CHECKING
import inspect, pickle
import inspect, pickle, zlib
if TYPE_CHECKING:
from server.GameBoard import GameBoard
@@ -28,7 +28,7 @@ class RedisGameBoardStore:
async def save(self, game_id:str, game_board:'GameBoard') -> None:
redis = await self._get_redis()
payload = pickle.dumps(game_board, protocol=pickle.HIGHEST_PROTOCOL)
payload = zlib.compress(pickle.dumps(game_board, protocol=pickle.HIGHEST_PROTOCOL), level=1)
await redis.set(self._key(game_id), payload, ex=self.ttl_seconds)
async def load(self, game_id:str):
@@ -36,7 +36,10 @@ class RedisGameBoardStore:
payload = await redis.get(self._key(game_id))
if payload is None:
return None
return pickle.loads(payload)
try:
return pickle.loads(zlib.decompress(payload))
except zlib.error:
return pickle.loads(payload)
async def delete(self, game_id:str) -> None:
redis = await self._get_redis()