final double cacheSizeInGB = 1.0;
HTreeMap cache = DBMaker
.memoryDirectDB()
.transactionDisable()
.make()
.hashMapCreate("test")
.expireStoreSize(cacheSizeInGB)
.make();
Random r = new Random();
Store store = Store.forEngine(cache.getEngine());
for(long counter=1; counter<1e8; counter++){
long key = r.nextLong();
byte[] value = new byte[1000];
r.nextBytes(value);
cache.put(key,value);
if(counter%1e5==0){
System.out.printf("Map size: %,d, counter %,d, store size: %,d, store free size: %,d\n",
cache.sizeLong(), counter, store.getCurrSize(), store.getFreeSize());
}
}
cache.close();