# UK Data Services - Redis Configuration for Performance Cache

# Network
bind 0.0.0.0
port 6379
protected-mode no

# Memory Management
maxmemory 256mb
maxmemory-policy allkeys-lru

# Persistence (for session storage)
save 900 1
save 300 10
save 60 10000

# Logging
loglevel notice
logfile "/data/redis.log"

# Performance
tcp-keepalive 300
timeout 0
tcp-backlog 511

# Security
# requirepass your_redis_password_here

# Database
databases 16

# Session storage database
# Database 0: General cache
# Database 1: Session storage
# Database 2: Application data cache

# Append-only file
appendonly yes
appendfilename "redis-appendonly.aof"
appendfsync everysec

# Compression
rdbcompression yes
rdbchecksum yes

# Client output buffer limits
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

# Slow log
slowlog-log-slower-than 10000
slowlog-max-len 128

# Latency monitoring
latency-monitor-threshold 100

# Memory usage optimization
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64