
It is just a Lua program that will run in the Redis engine's context. The script doesn't need to include any definitions of Lua function. The first argument is a string that consists of the script's Lua source code. In this example, EVAL takes two arguments. Here's our first example: > EVAL "return 'Hello, scripting!'" 0 We'll start scripting with Redis by using the EVAL command.

So all scripts may need to be reloaded by the application at any time if missing (after a server restart, fail-over to a replica, etc.).Īs of version 7.0, Redis Functions offer an alternative approach to programmability which allow the server itself to be extended with additional programmed logic. Please refer to the Redis Lua API Reference page for complete documentation.Īlthough the server executes them, Eval scripts are regarded as a part of the client-side application, which is why they're not named, versioned, or persisted. Presently, Redis supports a single scripting engine, the Lua 5.1 interpreter. Scripts are executed in Redis by an embedded execution engine. Such scripts can perform conditional updates across multiple keys, possibly combining several different data types atomically. Lua lets you run part of your application logic inside Redis.


Scripts can employ programmatic control structures and use most of the commands while executing to access the database.īecause scripts execute in the server, reading and writing data from scripts is very efficient. Redis lets users upload and execute Lua scripts on the server.
