I am searching for an embedded key-value data store which
I have found LevelDBJni , but it is designed for simple KV operation and unfriendly for counters. Are there better solutions?
Thanks.
With the Java library you can use a Map
with an AtomicInteger
as value.
In the following examples I use String
as datatype for the key.
Eg
Map<String, AtomicInteger> kvStore = new ...
To manipulate the counters you can then use
kvStore.get("...").addAndGet(10);
To retrieve also the updated value
AtomicInteger value = kvStore.get("...").addAndGet(10);
As AtomicInteger
is designed for concurrency a multi-threaded environmet should be no problem.
I cannot tell you how the performance of this is as I don't know your specific requirements so you have to determine this yourself.
嵌入式Java DB count-db( https://github.com/koendeschacht/count-db )在其API中提供了一个count方法,该方法应对此用例进行解答。
Take a look at http://www.mapdb.org . It is very high performance and offers a very familiar API (Java Map).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.