Skip to content

Instantly share code, notes, and snippets.

@gurbuzali
Created February 5, 2016 07:28
Show Gist options
  • Save gurbuzali/34589488f6b5352d92be to your computer and use it in GitHub Desktop.
Save gurbuzali/34589488f6b5352d92be to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
Config config = new Config();
MapConfig mapConfig = config.getMapConfig("map");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true).setWriteDelaySeconds(60).setImplementation(new MyStore());
mapConfig.setMapStoreConfig(mapStoreConfig);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
IMap<Object, Object> map = instance.getMap("map");
for (int i = 0; i < 10; i++) {
map.put(i, -1);
}
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
for (int i = 0; i < 10; i++) {
map.put(i, i);
}
}
static class MyStore implements MapStore {
@Override
public Object load(Object key) {
return null;
}
@Override
public Map loadAll(Collection keys) {
return null;
}
@Override
public Iterable loadAllKeys() {
return null;
}
@Override
public void store(Object key, Object value) {
System.err.println("store key: " + key + " value: " + value);
}
@Override
public void storeAll(Map map) {
System.err.println("size: " + map.size());
}
@Override
public void delete(Object key) {
}
@Override
public void deleteAll(Collection keys) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment