Interview Databases & Caching

Why are some Redis commands (KEYS, FLUSHALL) dangerous in production?

Databases & Caching · Advanced level

Answer

KEYS can block Redis by scanning the full keyspace, and FLUSHALL can delete the entire cache or datastore. In production I use SCAN/UNLINK, namespace isolation, ACL restrictions, and controlled cleanup jobs.

Technical explanation

Global hit ratio can hide bad key patterns; monitor by endpoint or key prefix where possible.

Large keys and hot keys can overload a single Redis thread or shard even when total cluster capacity looks fine.

Use SCAN and UNLINK instead of KEYS and mass DEL; restrict dangerous commands through ACLs or operational policy.

Hands-on example

Operational commands:

INFO stats

INFO memory

INFO commandstats

SLOWLOG GET 10

LATENCY LATEST

redis-cli --bigkeys -h <host> -p 6379

Safe cleanup pattern:

redis-cli --scan --pattern "session:*" | while read key; do redis-cli UNLINK "$key"; done

Pipeline warmup in batches instead of one command per network round trip.

Preparing for an interview?

Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.

More Databases & Caching interview questions

← All Databases & Caching questions