// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package dbcache;

import javax.cache.Caching;
import javax.cache.configuration.MutableConfiguration;

public class DAL_LocalCache extends DAL_Cache {
    public DAL_LocalCache(DAL real) {
        super(real);
        // this implementation use EHCache which is a very common choice for local cache
        cp = Caching.getCachingProvider("org.ehcache.jsr107.EhcacheCachingProvider");
        cm = cp.getCacheManager();
        big_cache = cm.getCache("local_big_cache");
        if(big_cache == null) {
            big_cache = cm.createCache("local_big_cache", new MutableConfiguration<Integer,Big>());
        }
        counter_cache = cm.getCache("local_counter_cache");
        if(counter_cache == null) {
            counter_cache = cm.createCache("local_counter_cache", new MutableConfiguration<String,Integer>());
        }
    }
}
