Skip to content

feat(cache): Smart caching strategy for dashboard & analytics (#127)#269

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

feat(cache): Smart caching strategy for dashboard & analytics (#127)#269
dagangtj wants to merge 1 commit intorohitdash08:mainfrom
dagangtj:feat/smart-caching-127

Conversation

@dagangtj
Copy link

Summary

Optimize performance with intelligent caching and automatic invalidation on data mutations.

Closes #127

Changes

  • Smart cache service: packages/backend/app/services/smart_cache.py

    • LRU in-memory cache with TTL support (Redis-ready)
    • Auto-invalidation: expense/bill/category mutations clear related caches
    • TTL presets: dashboard (2min), analytics (5min), categories (1hr), insights (10min)
    • @cached decorator for route-level caching
    • cache_key() helper for consistent key generation
    • Hit/miss stats tracking
  • Cache API: packages/backend/app/routes/cache.py

    • GET /cache/stats — cache hit rate and stats
    • POST /cache/invalidate — invalidate by event
    • POST /cache/clear — clear all cache
  • Tests: 18 test cases covering LRU, TTL, invalidation, API

Acceptance Criteria

  • Production ready implementation
  • Includes tests (18 cases)
  • Follows existing code patterns

…ash08#127)

- InMemoryCache with LRU eviction and TTL support
- SmartCache with auto-invalidation on data mutations
- Redis backend support with memory fallback
- TTL presets per data type (dashboard 2min, analytics 5min, etc.)
- Invalidation map: expense/bill/category mutations clear related caches
- Cache management API: stats, invalidate, clear
- @cached decorator for route-level caching
- 18 test cases
@dagangtj dagangtj force-pushed the feat/smart-caching-127 branch from e5e6a6d to f0aa433 Compare February 28, 2026 13:07
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