moltin / redis-scripts

Script to maintain Redis databases
9 stars 2 forks source link

Recomendation from @itamarhaber on Twitter #2

Open zot24 opened 8 years ago

zot24 commented 8 years ago
@zot24 cute - fyi: 1) use variadic DEL instead of the Lua script & 2) the new effects replication mode allows intermixing scans and dels..
itamarhaber commented 8 years ago

1) Because DEL accepts multiple keys, you can stop using https://github.com/moltin/redis-lua-scripts/blob/master/lua/del_keys.lua and just issue one statement. This is more performant as there are less round trips and context switches. The response from variadic DEL is an integer but since you're not doing anything with the del_keys.lua script reply that shouldn't matter.

2) Check out 3.2's (still in RC phase) new command replication mode as described in the EVAL's docs. After you call redis.replicate_commands(), you can mix non-deterministic (e.g. SCAN) and write (e.g. DEL) in scripts. That said, in this specific use case, doing so will be going against scripting's recommendations (i.e. explicitly declaring affected key names in scripts with the KEYS table) so never mind what I just said :)