Is there an embeddable Java alternative to Redis?

10,252

Solution 1

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.

Solution 2

Hazelcast provides a number of distributed data structure implementations which can be used as a pure Java alternative to Redis' services. You could then ship a single "jar" with all required dependencies to run your application. You may have to adjust for the slightly different primitives relative to Redis in your own application.

Commercial solutions in this space include Teracotta's Enterprise Ehcache and Oracle Coherence.

Share:
10,252

Related videos on Youtube

Andrew Mao
Author by

Andrew Mao

https://github.com/mizzao

Updated on June 11, 2022

Comments

  • Andrew Mao
    Andrew Mao almost 2 years

    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.

  • Andrew Mao
    Andrew Mao about 11 years
    Sounds very interesting...so I can run a one-node instance just for local lookups and stuff? I will check it out.
  • hama Mk
    hama Mk about 11 years
    @AndrewMao Yes it support a single node. And I added a link to Gauva's Table data structure also. good luck and happy hunting :-)
  • gyorgyabraham
    gyorgyabraham almost 11 years
    This definitely does not answer the question. While Guava is an extremely useful general library, it doesn't provide a key-value store. The results of these methods still have to be persisted in some way.
  • Andrew Mao
    Andrew Mao over 10 years
    @gyabraham actually, in many use cases Redis is not persisting the data, some other database is doing that. It is just used as a fast way to compute queries that would be nearly impossible using the database. In any case, Guava can't really replace the features of Redis.
  • Arun Gupta
    Arun Gupta over 10 years
    Jedis is just a Java API to Redis. The database still needs to be explicitly started outside the Java process.