redis-lua is a pure-Python library that eases usage of LUA scripts with Redis. It provides script loading and parsing abilities as well as testing primitives.
A code sample is worth a thousand words:
from redis_lua import load_script
# Loads the 'create_foo.lua' in the 'lua' directory.
script = load_script(name='create_foo', path='lua/')
# Run the script with the specified arguments.
foo = script.get_runner(client=redis_client)(
members={'john', 'susan', 'bob'},
size=5,
)
This sample code simply loads a LUA script from disk and executes it on the specified Redis instance by specifying named arguments of various types. How simpler can it get ?
Check out the documentation to find out more !
Just type:
pip install redis-lua
That's it.