Use SCAN and add support for redis://:password@hostname:port?db=1 urls #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First off, thanks for writing this 👍 . It helps with migrating data when hosting provider locks down some access to system.
Here are my changes:
Use REDIS SCAN instead of KEYS
SCAN preferred to KEYS for production use:
Optional URL Input Format
Adds support for redis:// type urls which are used in redis-cli, with
the optional extension of
?db=1
if db needs to be non-zero.Adds specs to verify the behavior. Preferentially chooses that type of
link parsing if the url starts with redis:// prefix. Otherwise falls
through to existing behavior.
Uses INFO to get full key count. This is incorrect when selecting a subset of keys... but the alternate way doesn't give any prediction of status bar Total count because we're gradually iterating through keyspace rather than preloading, as is done with
KEYS
. Seems like an acceptable tradeoff for now, but I could remove it from the PR if desired.Note
I brought in a different redis client in addition to current one because it cleanly supports the REDIS
SCAN
. This is a messy hack but it's working well enough for now.Cheers,
Zander