In this example, we used the value 0 because we didn't provide the script with any arguments, whether the names of keys or not. The second argument is the number of arguments that follow the script's body, starting from the third argument, representing Redis key names. 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. Enabling the composition of simple capabilities that are either missing from Redis or are too niche to a part of it.Blocking semantics that ensure the script's atomic execution.Data locality reduces overall latency and saves networking resources. Providing locality by executing logic where data lives.Scripting offers several properties that can be valuable in many cases. These semantics mean that all of the script's effects either have yet to happen or had already happened. While executing the script, all server activities are blocked during its entire runtime. Redis guarantees the script's atomic execution. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |