February 2018
Intermediate to advanced
382 pages
11h 33m
English
redis-py provides a very convenient register_script() function to register Lua scripts. register_script() will return a Script instance, which can be used as a function to invoke Lua scripts later. In the Using Lua recipe of Chapter 3, Data Features, we used SCRIPT LOAD and EVALSHA to cache a Lua script and reuse it. Let's see how we can do it in redis-py:
The content of updateJson.lua can be found in the Using Lua recipe of Chapter 3, Data Features.
Create RedisLuaDemo.py with the following code:

The output of the program will be the updated JSON value:
{"grade":"C","name":"Tina","sex":"female"}
Read now
Unlock full access