Skip to content

Instantly share code, notes, and snippets.

@egemenyildiz
Created July 1, 2015 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save egemenyildiz/d86d864806a861542871 to your computer and use it in GitHub Desktop.
Save egemenyildiz/d86d864806a861542871 to your computer and use it in GitHub Desktop.
[LUA] Redis bulk/batch operation scripts (rename, delete)
# Bulk deletes keys start with "prefix"
EVAL "for i, name in ipairs(redis.call('KEYS', 'prefix*')) do redis.call('DEL', name); end" 0
# Bulk renames keys start with "prefix" to "postfix".
# e.g. prefixwithtail -> postfixwithtail
EVAL "for i, name in ipairs(redis.call('KEYS', 'prefix*')) do local x = string.gsub(name, 'pre', 'post'); redis.call('RENAME', name, x); end" 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment