sidequest_bot.config_cache ========================== .. py:module:: sidequest_bot.config_cache .. autoapi-nested-parse:: TTL cache of guild configs so hot paths (every message) don't hit the API. Attributes ---------- .. autoapisummary:: sidequest_bot.config_cache.DEFAULT_TTL_SECONDS Classes ------- .. autoapisummary:: sidequest_bot.config_cache.GuildConfigCache Module Contents --------------- .. py:class:: GuildConfigCache(api: sidequest_bot.api_client.SideQuestAPI, *, ttl: float = DEFAULT_TTL_SECONDS) Per-guild config cache. Reads are served from memory for ``ttl`` seconds. Writes through :meth:`update` go to the API and replace the cached copy immediately, so changes made from slash commands apply without waiting for expiry. .. py:method:: get(guild_id: int) -> sidequest_common.schemas.GuildConfigSchema :async: Cached config, fetched from the API when missing or stale (one fetch per guild at a time). .. py:method:: invalidate(guild_id: int) -> None Drop the cached config so the next read refetches. .. py:method:: update(guild_id: int, changes: sidequest_common.schemas.GuildConfigUpdate) -> sidequest_common.schemas.GuildConfigSchema :async: Persist ``changes`` and cache the result. .. py:data:: DEFAULT_TTL_SECONDS :value: 60.0