feat: add Redis caching for recipe queries with automatic invalidation
All checks were successful
CI / update (push) Successful in 13s

Implements Redis caching layer for recipe endpoints to reduce MongoDB load and improve response times:

- Install ioredis for Redis client with TypeScript support
- Create cache.ts with namespaced keys (homepage: prefix) to avoid conflicts with other Redis applications
- Add caching to recipe query endpoints (all_brief, by tag, in_season) with 1-hour TTL
- Implement automatic cache invalidation on recipe create/edit/delete operations
- Cache recipes before randomization to maximize cache reuse while maintaining random order per request
- Add graceful fallback to MongoDB if Redis is unavailable
- Update .env.example with Redis configuration (REDIS_HOST, REDIS_PORT)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-07 20:25:07 +01:00
parent bfba0870e3
commit 1628f8ba23
10 changed files with 457 additions and 11 deletions

View File

@@ -41,6 +41,7 @@
"@sveltejs/adapter-node": "^5.0.0",
"chart.js": "^4.5.0",
"cheerio": "1.0.0-rc.12",
"ioredis": "^5.9.0",
"mongoose": "^8.0.0",
"node-cron": "^4.2.1",
"sharp": "^0.33.0"