Skip to content

Instantly share code, notes, and snippets.

@paulcalabro
Forked from egemenyildiz/redis_bulk.sh
Created October 23, 2015 19:11
Show Gist options
  • Save paulcalabro/06402c3c5e7d8f268efc to your computer and use it in GitHub Desktop.
Save paulcalabro/06402c3c5e7d8f268efc 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