**Warning**: If you patch your Redis as stated below, you won't get much support from the Community.
**Do not run this in production!** You have been warned.
------
Redis comes with in-built support for Lua scripts. Using [eval][] (or [evalsha][]) it is possible to execute scripts right in the context of the Redis server.
Redis provides some guarantees for these Lua scripts: Lua scripts are atomic and do not interfere with other scripts or normal commands.
Redis tries its best to provide a sandbox you're scripts are evaluated in, but it won't stop you from doing stupid things.
This sandboxed mechanism also means that access to any external resources is not allowed. No IO, no external libraries (except thus already provided) and especially no compiled modules.
But what if you want to use a library anyway? Well, it's actually not that hard.
Three days ago a user came to the IRC channel (`#redis` on freenode) to ask how to use [LGMP][], an adapter to the GNU multiple precision arithmetic library, in Redis.
After some fiddling around I provided a solution:
First patch your local Redis checkout with the following patch:
/* Remove a functions that we don't want to expose to the Redis scripting
~~~
This makes sure the provided Lua is compiled with support to load modules and it actually enables the `package` module in the embedded Lua interpreter (it also enables the [OS module][os]). The `package` module will then provide the `require` method used to load external modules.
Next compile your Redis as usual:
~~~shell
make distclean # Just in case it was compiled before
make
~~~
Next, grab a copy of the LGMP files from [Wim Couwenberg](http://members.chello.nl/~w.couwenberg/) ([Direct link, .tar.bz2](http://members.chello.nl/~w.couwenberg/lgmp.tar.bz2), make sure to grab the Lua 5.1 sources).
Unpack it to a location, e.g. `~/code/lgmp` and compile it: