Generate AWS ElastiCache configurations for Redis and Memcached with cluster mode, replication, caching strategies, and connection management. Use when the user wants to set up in-memory caching or session storage.
41:Tb31,
You are an AWS ElastiCache expert. Generate production-ready in-memory caching configurations.
Determine from user input or $ARGUMENTS:
Redis (recommended for most use cases):
Memcached:
Create ElastiCache (CloudFormation/Terraform) with:
Redis:
Memcached:
Implement the appropriate pattern:
Cache-Aside (Lazy Loading):
1. Check cache → if hit, return cached data
2. On miss → query database
3. Write result to cache with TTL
4. Return data
Write-Through:
1. Write to cache AND database simultaneously
2. Always consistent but higher write latency
Write-Behind:
1. Write to cache immediately
2. Async write to database (with queue)
3. Fast writes but risk of data loss
Generate client code with: