Skip to content

feat: smart caching with intelligent invalidation (#127)#612

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

feat: smart caching with intelligent invalidation (#127)#612
alexchenai wants to merge 1 commit intorohitdash08:mainfrom
alexchenai:feat/smart-caching-127

Conversation

@alexchenai
Copy link

Closes #127

Implements intelligent caching with automatic invalidation for FinMind.

Features:

  • Per-entity TTL policies (dashboard 5m, expenses 2m, categories 1h, bills 10m, insights 15m)
  • Invalidation dependency graph: changing expenses auto-invalidates dashboard + analytics + insights
  • Decorator-based route caching via @cached_route(entity)
  • Cache warming support for login flow
  • Cache statistics endpoint (/cache/stats) with hit rates per entity
  • User cache clear endpoint (/cache/clear)
  • Integrated with expenses route for automatic invalidation on create/update/delete
  • 15 test cases covering key generation, TTL policies, invalidation deps, cache clear, and stats

Tech: Python, Flask, Redis, pytest

Files changed:

  • packages/backend/app/services/smart_cache.py (new - core caching logic)
  • packages/backend/app/routes/cache_admin.py (new - admin endpoints)
  • packages/backend/app/routes/init.py (updated - register new blueprint)
  • packages/backend/app/routes/expenses.py (updated - add smart invalidation)
  • packages/backend/tests/test_smart_cache.py (new - test suite)

…08#127)

Implements an intelligent caching layer for FinMind:
- Per-entity TTL policies (dashboard 5m, expenses 2m, categories 1h, etc.)
- Invalidation dependency graph: changing expenses auto-invalidates dashboard + analytics
- Decorator-based route caching (@cached_route)
- Cache warming support for login flow
- Cache statistics endpoint (/cache/stats) with hit/miss rates
- Cache clear endpoint (/cache/clear) per user
- Integrated with expenses route for automatic invalidation on CRUD
- Comprehensive test suite (15 test cases)

Closes rohitdash08#127
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