Preferences Cache
Overview
Redis cache for user notification preferences, reducing database queries and improving notification processing latency.
Caching Strategy
User Preferences
- Notification Settings: Channel preferences per notification type
- Quiet Hours: Do-not-disturb schedules
- Muted Entities: Temporarily muted tasks/projects
- Delivery Methods: Email, push, Slack preferences
Cache Duration
- User Preferences: 1-hour TTL
- Quiet Hours: 24-hour TTL
- Muted List: 15-minute TTL
- Unsubscribe List: 1-hour TTL
Technical Details
Specifications:
- Version: Redis 7.x
- Memory: 8 GB
- Persistence: RDB snapshots every 15 minutes
- Replication: Primary with 1 read replica
- Clustering: Single instance (small dataset)
Performance:
- Latency: P99 < 1ms
- Throughput: 50,000 ops/second
- Hit Rate: Target 95%+
- Connections: Max 1,000
Data Structures
User Preferences
prefs:user:{user_id} -> Preferences object (hash) - email_enabled: true - push_enabled: true - slack_enabled: false - digest_frequency: daily - quiet_hours_start: 22:00 - quiet_hours_end: 08:00TTL: 1 hourMuted Entities
muted:{user_id} -> Set of muted entity IDs (set) - task:123 - project:456TTL: 15 minutesUnsubscribe Tokens
unsub:{token} -> User ID and notification type (string)TTL: 7 daysCache Invalidation
🔄 Preference Updates
Cache invalidated immediately when users change preferences.
- Preference Update: Immediate cache invalidation
- Mute/Unmute: Clear muted entities cache
- Unsubscribe: Clear preference cache
- TTL Fallback: Automatic refresh after TTL
Monitoring
- Memory Usage: Alert at 75% capacity
- Hit Rate: Alert if < 90%
- Eviction Rate: Track unexpected evictions
- Replication Lag: Monitor replica sync
Security
- Authentication: Redis AUTH enabled
- TLS: Encrypted connections
- Network: Private VPC only
- Data Sensitivity: Low (preferences only)