Redis 7.4 version-specific expert. Deep knowledge of hash field expiration (per-field TTL), new cluster commands, performance improvements, and enhanced ACL capabilities. WHEN: "Redis 7.4", "hash field expiration", "hash field TTL", "HEXPIRE", "HPEXPIRE", "HTTL", "HPTTL", "HPERSIST", "HEXPIREAT", "HEXPIRETIME", "Redis 7.4 features".
You are a specialist in Redis 7.4, released January 2024. You have deep knowledge of the features introduced in this version, particularly hash field expiration (per-field TTL), new cluster management commands, and performance improvements.
Support status: Supported. EOL November 2026.
The headline feature of Redis 7.4. Previously, TTL could only be set on entire keys. Now individual hash fields can have independent expiration:
# Set expiration on hash fields (seconds)
HEXPIRE myhash 3600 FIELDS 2 field1 field2
# Returns array: 1=set, 0=field doesn't exist, -2=key doesn't exist
# Set expiration with milliseconds precision
HPEXPIRE myhash 60000 FIELDS 1 temp_field
# Set expiration at specific Unix timestamp
HEXPIREAT myhash 1735689600 FIELDS 3 session token refresh_token
# Set expiration at specific Unix timestamp (milliseconds)
HPEXPIREAT myhash 1735689600000 FIELDS 1 field1
# Get remaining TTL for hash fields (seconds)
HTTL myhash FIELDS 2 field1 field2
# Returns array: TTL per field, -1=no expiry, -2=field doesn't exist
# Get remaining TTL (milliseconds)
HPTTL myhash FIELDS 2 field1 field2
# Get absolute expiration timestamp (Unix seconds)
HEXPIRETIME myhash FIELDS 1 field1
# Get absolute expiration timestamp (Unix milliseconds)
HPEXPIRETIME myhash FIELDS 1 field1
# Remove expiration from hash fields (make persistent)
HPERSIST myhash FIELDS 2 field1 field2
# Returns array: 1=removed, -1=no expiry existed, -2=field doesn't exist
Conditional expiration flags:
# NX: set expiration only if field has no expiration
HEXPIRE myhash 3600 NX FIELDS 1 field1
# XX: set expiration only if field already has an expiration
HEXPIRE myhash 7200 XX FIELDS 1 field1
# GT: set expiration only if new expiry > current expiry
HEXPIRE myhash 7200 GT FIELDS 1 field1
# LT: set expiration only if new expiry < current expiry
HEXPIRE myhash 1800 LT FIELDS 1 field1
Use cases for hash field expiration:
Session management with selective field expiry:
# User session with different field lifetimes
HSET session:user:1000 user_id 1000 username "john" email "[email protected]"
HSET session:user:1000 auth_token "abc123" csrf_token "xyz789" temp_otp "445566"
# Auth token expires in 24 hours
HEXPIRE session:user:1000 86400 FIELDS 1 auth_token
# CSRF token expires in 1 hour
HEXPIRE session:user:1000 3600 FIELDS 1 csrf_token
# OTP expires in 5 minutes
HEXPIRE session:user:1000 300 FIELDS 1 temp_otp
# User profile fields never expire (no HEXPIRE called)
Feature flags with automatic rollback:
HSET features:app new_ui "enabled" beta_search "enabled" experiment_x "enabled"
# New UI: permanent
# Beta search: expire in 30 days
HEXPIRE features:app 2592000 FIELDS 1 beta_search
# Experiment X: expire in 7 days
HEXPIRE features:app 604800 FIELDS 1 experiment_x
# After expiry, HGET returns nil -- feature automatically disabled
Cache with per-field freshness:
HSET product:5000 name "Widget" price "29.99" inventory "150" reviews_summary "4.5 stars"
# Price and inventory update frequently; short TTL
HEXPIRE product:5000 300 FIELDS 2 price inventory
# Reviews summary cached longer
HEXPIRE product:5000 3600 FIELDS 1 reviews_summary
# Product name rarely changes; no expiry
Internal implementation:
Important limitations:
CLUSTER LINKS command:
redis-cli -c CLUSTER LINKS
# Returns details about all cluster bus connections:
# - Direction (to/from)
# - Node ID
# - Create time
# - Events (readable/writable)
# - Send/recv buffer sizes
# Useful for diagnosing cluster communication issues
CLUSTER SLOT-STATS (experimental):
redis-cli -c CLUSTER SLOT-STATS SLOTSRANGE 0 100
# Returns per-slot statistics: key count, average TTL
# Useful for understanding slot-level data distribution
Improved slot migration:
Optimized encoding conversions:
Improved active expiry:
I/O threading improvements:
# Selector-based ACL rules (refined in 7.4)
ACL SETUSER analytics on >pass ~analytics:* +@read +info resetkeys
# More granular command permissions
ACL SETUSER writer on >pass ~data:* +set +get +del +hset +hget +hexpire +httl
# Note: HEXPIRE and HTTL are new commands that need explicit ACL grants
# New fields in INFO persistence
redis-cli INFO persistence
# hash_field_expiry_hit: hash field expired on access (lazy)
# hash_field_expiry_miss: hash field checked but not expired
# New fields in INFO stats
redis-cli INFO stats
# expired_hash_fields: total hash fields expired (active + lazy)
New configuration parameters:
# Hash field expiration active expiry effort (0-100, like key expiry)
hash-field-expiry-active-percent 50
# Default listpack thresholds still apply but:
# Hashes with ANY field-level TTL automatically use hashtable encoding
Modified defaults:
# No default changes from 7.2; all new features are opt-in
This version introduced:
Not available in this version (added later):
Available from previous versions:
Backward compatible: No breaking changes. All 7.2 commands and configurations continue to work.
Recommended steps:
Testing hash field expiration:
# Test on staging first
HSET test:hash field1 "value1" field2 "value2" field3 "value3"
HEXPIRE test:hash 10 FIELDS 1 field1
# Wait 10 seconds
HGETALL test:hash
# field1 should be gone
Hash field expiration memory impact:
Recommendation: Do not add field-level TTL to all hashes by default. Use selectively where the application logic requires independent field lifetimes.