Looking for a lightweight java-compatible in-memory key-value store [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-03 01:52:26
Fuad Malikov

You can try Hazelcast. Just add hazelcast.jar to your classpath. And start coding

java.util.Map map = Hazelcast.getMap("myMap");

You'll get an in-memory, distributed, dynamically scalable data grid which performs super fast.

Your question could mean one of two things.

If you mean a data structure for storing key-value pairs, use one of the Map instances that are a standard part of the JDK.

If however you are after an in-memory key-value store then I would suggest taking a look at EHCache or even memcached.

Chronicle-Map is a strong alternative.

  • Pure Java, simply java.util.Map implementation
  • Stores the data off-heap, optionally persisted to disk via memory-mapped files
  • Open source, permissive Apache 2.0 license
  • Incredibly fast, can manage millions of updates/queries per second (see exact numbers)

jdbm works great for this sort of thing. It's intended for storing on disk in a paged file, provides for basic transaction support (no guarantees on isolation, but ACD are covered). We've used it in a production system with fairly wide deployment and have been quite pleased with the performance, stability, etc...

Consider using jredis. It's a Java client for Redis, a persistent key-value store. There's also a JDBC driver for it: code.google.com/p/jdbc-redis/.

I know this is a two-year old post but I've been messing around with Infinispan recently and I like it so far. I'm not an expert by any means but it was not too difficult for me to set up a distributed cache with a few nodes and I was pulling some data from them in about an hour.

MapDb is an alternative to Berkley with a friendly Apache 2 license.

  • Provides key-value store via java's Map interface
  • Lightweight (300KB jar)
  • Fast and threadsafe
  • Persists changes to disk if you want to
  • Many other features

There are lightweigh or embedded dbs like HSQLDB, Derby, SQLite But like others don't understand why you need a db to store key/values...

Why not a Map? Need to keep key/values on app reboot?

Also it's perhaps not what you need but with html5 on up to date browsers you have localStorage that permits you to store key/values in the browser using javascript.

I would recommend to try a Redisson. You will able to use distributed and scalable Map or ConcurrentMap and other (Set, List, Queue, Lock ...) implementations on top of high performance key-value Redis server.

Easy example:

Redisson redisson = Redisson.create();

ConcurrentMap<String, SomeObject> map = redisson.getMap("anyMap");

...

redisson.shutdown();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!