Reputation: 550
Currently i am using hazelcast as a distributed cache for my application. It takes in a key and gives me the values. But, it will be more helpful in my application if the cache can accept multiple keys and return the corresponding values, in one function call. Can hazelcast do it? Or is there any alternate solution, like EHCache or Redis ?
Upvotes: 0
Views: 1553
Reputation: 10763
Redis has JCache API (JSR-107) implementation through Redisson framework
Upvotes: 0
Reputation: 1236
Yes, the standard JCache API supports this. See: https://github.com/jsr107/jsr107spec/blob/master/src/main/java/javax/cache/Cache.java
The only implementation of JCache that I'm aware of today is Oracle Coherence; see: http://docs.oracle.com/middleware/1213/coherence/develop-applications/jcache_part.htm
For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.
Upvotes: 1
Reputation: 1709
Hazelcast IMap has the getAll api for this. Basically
Map IMap.getAll(keys);
gives you the key-values for the given set of keys.
Upvotes: 3
Reputation: 21
redis can help you do this via the MGET command and in addition it gives you loads of Data structures through which you can get values from lots of keys.
SET a 10
SET b 20
MGET a b
1)10
2)20
HSET "hash name" "a" 10
HSET "hash name" "b" 20
HGETALL "hash name"
1)a
2)10
3)b
4)20
The above example shows how you can harness redis to do what you need to do
Upvotes: 1
Reputation: 1805
i am not sure about redis or hazle cast but ehcache has this. Check this out
http://ehcache.org/apidocs/net/sf/ehcache/Ehcache.html
It has this method Map getAll(Collection keys) and bunch of more bulk operation methods
check this out as well for some more explanation
http://dancing-devil.blogspot.com/2011/04/ehcache-bulk-operation-apis.html
The upcoming JSR107 / JCache standard has bulk operations defined. So every standards compliant cache will have this.
Upvotes: 2