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