I am a Sr. Software Developer at Oracle Cloud. The opinions expressed here are my own and not necessarily those of my employer.
Redis modules
A couple of months ago I had a chance to attend RedisConf and present about using Rails with Redis. You can read my blog post about it here or watch the presentation.
At the conference RedisLabs announced new Redis Modules feature. You can read the details at this post by antirez. The feature is still in beta but RedisLabs and antirez are working hard to improve it before official release. What I wanted to share are my personally expereince and lessions learned from configuing Redis with modules. You can also watch the video from RedisConf. Dislaimer: this is a personal blog post and the process for configuring Redis Modules might change before the official release.
To get modules to work you must use UNSTABLE branch. If you are using a hosted service like RedisLabs Cloud or AWS ElastiCache you are out of luck. If you truly want to run this in prod you would need to setup your own server. Now, that you have been warned here are the steps that I went through.
First you need to clone Redis repo. I am assuming you have all necessary Linux libraries for compiling the code.
You should see standard Redis log output. Make you sure says "Redis 999.999.999"
(that means you are on unstable branch). Run src/redis-cli
to make sure you can connect and do basic GET / SET commands.
Now let’s get to modules. You can see them listed here. The ones that looked interesting to me are rxkeys/hashes/sets. They are all part of the same GitHub repo.
You will now see rxstrings.so, rxsets.so, etc files in redex/src.
Open redis/redis.conf file and add these lines. You can see basic instructions around line 40.
Stop Redis with src/redis-cli shutdown
and start it again with src/redis-server redis.conf
. You should see something like this in your log: * Module 'rxgeo' loaded from /path/to/redex/src/rxgeo.so
.
If you are not using unstable branch and you try to start Redis with loadmodule /path/to/my_module.so
you will see this error in your log:
Now you can run new commands like PKEYS.
The question is how could you use it from your application. Here is an example for Redis Ruby client
Read redex repo for more examples. Modules are a very interesting feature and I am looking forward to learning more about them.