Persistence (RDB vs AOF), high availability, connect from Python and Node, deploy with Upstash.
# RDB (Redis Database Backup)
# Snapshots: saves the dataset to disk at intervals
# Fast to restore, compact file, small performance impact
# Risk: lose data between last snapshot and crash
# AOF (Append Only File)
# Logs every write operation
# More durable, can recover to exact state before crash
# Larger file, slightly slower writes
# In redis.conf:
save 900 1 # RDB: save after 900s if 1 key changed
save 300 10 # save after 300s if 10 keys changed
appendonly yes # enable AOF
appendfsync everysec # fsync every second (good balance)pip install redis
import redis
r = redis.Redis(
host='localhost',
port=6379,
decode_responses=True # auto-decode bytes to strings
)
r.set('key', 'value')
print(r.get('key')) # 'value'
# Pipeline: batch commands (one round trip)
pipe = r.pipeline()
pipe.set('a', 1)
pipe.set('b', 2)
pipe.incr('a')
pipe.execute()# Upstash = fully managed Redis, serverless pricing
# Free tier: 10,000 commands/day
# No server to manage, works in Vercel/Netlify edge functions
# Get UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN
# from upstash.com
# Node.js
npm install @upstash/redis
import { Redis } from '@upstash/redis';
const redis = Redis.fromEnv();
await redis.set('key', 'value');
const val = await redis.get('key');redis.Redis(decode_responses=True) for string responses.