Skip to content

Instantly share code, notes, and snippets.

@itamarhaber
Last active April 19, 2017 21:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itamarhaber/f3c82a8553abd8d7750c to your computer and use it in GitHub Desktop.
Save itamarhaber/f3c82a8553abd8d7750c to your computer and use it in GitHub Desktop.
Redis suffix search function in Lua. Call with key name of search terms set and the argument to search
local res = redis.call("zrangebylex", KEYS[1], "\[" .. ARGV[1]:reverse(), "\[" .. ARGV[1]:reverse() .. "\\xff")
for k, v in pairs(res) do
res[k] = v:reverse()
end
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment