Overview - SCAN for safe key iteration
What is it?
SCAN is a Redis command that lets you safely go through all keys in the database without blocking the server. Unlike commands that return all keys at once, SCAN returns small batches of keys each time you call it. This way, you can iterate over keys even in large databases without causing delays or crashes.
Why it matters
Without SCAN, fetching all keys at once can freeze Redis, making your app slow or unresponsive. SCAN solves this by spreading the work into small steps, so Redis stays fast and responsive. This is important for real-world apps that store lots of data and need to find keys safely.
Where it fits
Before learning SCAN, you should know basic Redis commands and understand what keys and databases are. After SCAN, you can learn about other cursor-based commands like SSCAN, HSCAN, and ZSCAN for iterating sets, hashes, and sorted sets.