What is Redis ?

We all might be familiar with [Redis][1] .

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][2]

Do [try redis][3] it has a nice interactive tutorial.

To install and setup redis on your machine see [how-to-install-and-use-redis][4]

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][5] 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.
[1]: http://redis.io/
[2]: http://en.wikipedia.org/wiki/Redis_(dbms)
[3]: http://try.redis.io/
[4]: https://www.digitalocean.com/community/articles/how-to-install-and-use-redis
[5]: http://redis.io/commands/EVAL