Is there an embeddable Java alternative to Redis?

Andrew Mao picture Andrew Mao · Feb 11, 2013 · Viewed 9.7k times · Source

According to this thread, Jedis is the best thing to use if I want to use Redis from Java.

However, I was wondering if there are any libraries/packages providing similarly efficient set operations to those that already exist in Redis, but can be directly embedded in a Java application without the need to set up separate servers. (i.e., using Jetty for web server).

To be more precise, I would like to be able to do the following efficiently:

  1. There are a large set of M users (M not known in advance).
  2. There are a large set of N items.
  3. We want users to examine items, one user/item at a time, which produces a stored result (in a normal database.)
  4. Each time a user arrives, we want to assign to that user the item with the least number of existing results that the user has not already seen before. This produces an approximate round-robin assignment of the items over all arriving users, when we just care about getting all items looked at approximately the same number of times.

The above happens in a parallelized fashion. When M and N are large, Redis accomplishes the above much more efficiently than SQL queries. Is there some way to do this using an embeddable Java library that is a bit more lightweight than starting a Redis server?

I recognize that it's possible to write a pile of code using Java's concurrency libraries that would roughly approximate this (and to some extent, I have done that), but that's not exactly what I'm looking for here.

Answer

eSniff picture eSniff · Mar 7, 2013

Have a look at project voldemort . It's an distributed key-value store created by Linked-In, and it supports the ability to be embedded.

In the quick start guide is a small example of running the server embedded vs. stand-alone.

VoldemortConfig config = VoldemortConfig.loadFromEnvironmentVariable();
VoldemortServer server = new VoldemortServer(config);
server.start();

I don't know much about Redis, so I can't compare them feature to feature. In the project we used Voldemort, we used it's readonly backing store with great results. It allowed us to "precompile" a bi-daily database in our processing data-center and "ship it" out to edge data-centers. That way each edge data-center had a local copy of it's dataset.

EDIT: After rereading your question, I wanted to add Gauva's Table -- This Table DataStructure may also be something your looking for and is simlar to what you get with many no-sql databases.