What is Redis ?
We all might be familiar with [Redis] .
For those who are not - It's a "NoSQL" key-value data store. More precisely, it is a data structure server.
To read more - [Redis-Wiki]
Do [try redis] it has a nice interactive tutorial.
To install and setup redis on your machine see [how-to-install-and-use-redis]
What is LUA ?
LUA is an embeddable scripting language. About LUA - http://www.lua.org/about.html
Redis >= 2.6 supports embedded scripting language.
Lets give a try to it.
To run a script in redis we need to use [EVAL] command.
A Lua script file should be saved with .lua extension
local msg = "Hello, world!" return msg
Save this file locally as hello.lua and run it like so:
redis-cli EVAL "$(cat hello.lua)" 0
Running this will print “Hello, world!”. The first argument of EVAL is the complete lua script — here we’re using the cat command to read the script from a file. The second argument is the number of Redis keys that the script will access. Our simple “Hello World” script doesn’t access any keys, so we use 0.
Subscribe to Engineering At Kiprosh
Get the latest posts delivered right to your inbox