stickermule / rump

Hot sync two Redis servers using dumps.
MIT License
491 stars 94 forks source link

Add support to sync only keys matching a certain pattern #16

Closed fzunino closed 5 years ago

fzunino commented 7 years ago

I've used this tool it in the past and it works great, but now I have a case in which I need to dump keys that only match a certain pattern instead of dumping all the keys of a DB.

MATCH option of SCAN command can be used to add this support.

The following commit https://github.com/fzunino/rump/commit/67bc2e1dac6d46019019a8f6cf6996ba8a02cf70 adds this support adding an optional command line argument called match and using * as default value, maintaining the current semantic.

Let me know and I can submit a PR with this commit.

nixtrace commented 7 years ago

@fzunino Yes, that's great idea! Let's keep the new argument optional. :+1:

nixtrace commented 5 years ago

Hi,

We just released Rump 1.0.0 and dropped support for MATCH, considering that it could lead to inconsistencies since the filter is applied after SCAN: https://redis.io/commands/scan#the-match-option

It is important to note that the MATCH filter is applied after elements are retrieved from the collection, just before returning data to the client. This means that if the pattern matches very little elements inside the collection, SCAN will likely return no elements in most iterations.