package cpe.hapa.dao;
import java.util.HashMap;
import java.util.Map;
import javax.cache.Cache;
import javax.cache.CacheException;
import javax.cache.CacheFactory;
import javax.cache.CacheManager;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.jsr107cache.GCacheFactory;
public class DatacacheSingleton {
private static Cache datacache = null;
private DatacacheSingleton() {
}
public static Cache getInstance() throws CacheException {
if(datacache == null) {
Map props = new HashMap();
props.put(MemcacheService.SetPolicy.SET_ALWAYS, true);
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
datacache = cacheFactory.createCache(props);
}
return datacache;
}
}