On Tue, Feb 24, 2015 at 09:24:41AM -0800, phpguru wrote:
> We all know that redis-cli> keys pattern* is expensive; would it be
> beneficial to add <from> <to> as args, like sets have, so you could do
> things like paginate through?
No, because the cost of KEYS is almost entirely in the need to scan the entire
keyspace looking for matches. There would be a slight benefit for cases
where you only wanted the first N matches, but that would be tempered by the
"Schlemiel the Painter Algorithm" aspect of the repeated scans for each
pagination request, if you were trying to go through the entire keyspace,
bit by bit.
As has been suggested, if you want to deal with the keyspace bit by bit, use
SCAN.
- Matt