Package cpe.hapa.dao

Source Code of cpe.hapa.dao.DatacacheSingleton

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;
  }
}
TOP

Related Classes of cpe.hapa.dao.DatacacheSingleton

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.