Skip to main content


Showing posts from May, 2017

Implementing @ApacheIgnite's cache store (part II)

Apache Ignite’s CacheStore interface is an API for cache persistence storage for read-through and write-through behavior.  When implementing this interface, you choose the type of key and value object alike -- similar to a map.  This follows the pattern established by the CacheLoader and CacheWriter interfaces CacheStore extends of the JSR107 specification.  In many cases, having a specific implementation for each method when implementing this interface may not be necessary, so Apache Ignite has a CacheStoreAdapter for this purpose.
Since Caches so closely resemble Maps, perhaps we should begin our discussion with a cache implementation that is essentially a HashMap store:
public class HashMapStore extends CloudStoreAdapter {
private final Map<Object, Object> map = new HashMap<>();
@Override public void loadCache(IgniteBiInClosure c, Object … args) {
for(Map.Entry e : map.entrySet()) { c.apply(e.getKey(), e.getValues()); }
@Override public Object load(Object key) { Return map.get(k…