Skip to content

feat: smart caching strategy for dashboard & analytics#585

Open
mendarb wants to merge 1 commit intorohitdash08:mainfrom
mendarb:feat/smart-caching-127
Open

feat: smart caching strategy for dashboard & analytics#585
mendarb wants to merge 1 commit intorohitdash08:mainfrom
mendarb:feat/smart-caching-127

Conversation

@mendarb
Copy link

@mendarb mendarb commented Mar 20, 2026

Summary

  • Add in-memory caching layer using Flask-Caching with SimpleCache backend
  • Dashboard queries cached with 5-minute TTL, analytics with 15-minute TTL
  • Cache key based on user_id + query parameters (MD5 hash)
  • Cache invalidation triggered on expense, bill, and category CRUD operations
  • Add X-Cache-Hit response header (true/false) for debugging
  • Add flask-caching==2.3.0 dependency

Closes #127

Test plan

  • First dashboard request returns X-Cache-Hit: false
  • Second identical request returns X-Cache-Hit: true
  • Creating/updating/deleting an expense invalidates dashboard cache
  • Creating a bill invalidates dashboard cache
  • Category CRUD (create, update, delete) each invalidate dashboard cache
  • Different month query params produce separate cache entries
  • Analytics (insights) endpoint uses 15-minute TTL

🤖 Generated with Claude Code

…hitdash08#127)

Add Flask-Caching SimpleCache layer in front of existing Redis cache.
Dashboard queries cached with 5-min TTL, analytics with 15-min TTL.
Cache keys incorporate user_id + query params. CRUD operations on
expenses, bills, and categories trigger cache invalidation. Adds
X-Cache-Hit response header for debugging. Includes comprehensive tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mendarb mendarb requested a review from rohitdash08 as a code owner March 20, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart caching strategy for dashboard & analytics

1 participant