perf: add caching for frequently-accessed stable data #91
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#91
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Several frequently-called service methods fetch data that rarely changes but have no caching.
league_service.get_current_state()— no cachetransaction_builder.validate_transaction()on every validation render (line 515)transaction_service.get_pending/processed_transactions()on every invocationstandings_service.get_league_standings()— no cacheget_team_standings()andget_standings_by_division()both fetch full standings, then filter client-sidedice/rolls.py:359–373— embed color lookup on every dice roll_get_channel_embed_color()parses channel name for team abbreviation, then callsteam_service.get_team_by_abbrev()get_teams_by_owner()— potentially 2 API calls per dice roll/ab,/d20,/fielding,/jumpare the highest-frequency commandsplayer_service.get_top_free_agents()— no cacheFix
Add
@cached_api_call(ttl=...)or@cached_single_item(ttl=...)decorators where appropriate. For the embed color lookup, a simple in-memory dict cache keyed by channel ID with TTL is sufficient.Impact
MEDIUM-HIGH — The dice roll color lookup affects the most frequently used commands. The league state caching affects transaction workflows.
PR #120 opened: #120
Added caching to all four locations identified in the issue:
league_service.get_current_state()→@cached_single_item(ttl=60)(Redis)standings_service.get_league_standings()→ in-memory dict cache, 10-minute TTL (StandingsService doesn't extend BaseService so used the autocomplete.py pattern)player_service.get_free_agents()→@cached_api_call(ttl=300)(Redis, benefits get_top_free_agents too)dice/rolls.py _get_channel_embed_color()→ in-memory dict cache keyed by channel_id, 5-minute TTL