I recently needed to delete millions of Redis keys in production and found that the standard approaches were too slow. Here's a solution I developed that's proven to be blazingly fast, using Go's concurrency features and Redis's UNLINK command.
When working with Redis at scale, deleting keys by prefix can become a bottleneck. The naive approach of using DEL command sequentially is painfully slow. This implementation solves that by:
- Using batch processing to reduce network calls
- Leveraging goroutines for concurrent deletions