Lua: A Guide for Redis Users

Last updated 1 year ago by Brian P O'Rourke

Lua

You’ve heard that Redis has an embedded scripting language, but haven’t given it a try yet? Here’s a tour of what you need to understand to use the power of Lua with your Redis server.

Hello, Lua!

Our first Redis Lua script just returns a value without actually interacting with Redis in any meaningful way:

local msg = "Hello, world!" return msg

This is as simple as it gets. The first line sets up a local variable with our message, and the second line returns that value from the Redis server to the client. Save this file locally as hello.lua and run it like so:

redis-cli --eval hello.lua

Read full Article