示例#1
0
def get_current_game_config() -> models.GameConfig:
    """Get game config from cache is cached, cache it otherwise."""
    with utils.redis_pipeline(transaction=True) as pipe:
        cache_helper(
            pipeline=pipe,
            cache_key=CacheKeys.game_config(),
            cache_func=caching.cache_game_config,
            cache_args=(pipe,),
        )

        result, = pipe.get(CacheKeys.game_config()).execute()

    game_config = models.GameConfig.from_json(result)
    return game_config
示例#2
0
def cache_game_config(pipe: Pipeline) -> None:
    """Put game config to cache (without round or game_running)."""
    game_config = game.get_db_game_config()
    data = game_config.to_json()
    pipe.set(CacheKeys.game_config(), data)