/ BigData

Simpe Redis: A Simple Interface For Using Redis

In my last post, I talked briefly about Redis and how to install it. In this post, I will try to go deeper and will introduce a very simple interface for using Redis in seconds from Java.

At first I would like to introduce you to some important commands in Redis.

Redis has a very nice documentation so I will only list them with reference links for each one. If you are interested in playing with these commands, you can use the interactive web redis command line from here

String Value Storage Commands

Mainly for very basic scenaios

Hashed Value Storage Commands

Mainly with data structures and complex objects

Administration Commands

Good To know :)

For the full list of commands, check this.

The next step from here should be using Redis as part of your project. As I mentioned in the previous blog, a lot of clients are available for redis for different languages. But I will focus here on Java users.

One of the best libraries available for Java is Lettuce. It may seems complex some how but it shines very well when it comes to scalability scenarios.

One of the missing things in Lettuce is a simple interface for very basic usage scenarios (without having to write too much code or be aware of the very specific details of the library.)

Here comes my interface simple-redis.

Let's see a code snippet !

You just need to pass a redis client object from lettuce and you can in seconds cache, retrieve and clear your data without caring about anything else. A default provided java serializer allows Simple-Redis to handle java objects just like Strings.

Using Simple-Redis won't prevent you from making use of all lettuce power. Simple-Redis is opensource and available on github. I hope you would consider it in your next projects, especially when you have simple caching scenario to implement.

If you have any feedback, please don't hesitate to reach me either through mail or the comments inside this post. Thanks a lot !