一、前言
关于gaejtools源码包中的appengine.util.MemcacheUtil缓存工具类,基于google的com.google.appengine.api.memcache.MemcacheServiceFactory、 com.google.apphosting.api.ApiProxy缓存服务进行实现(参见appengine-api-1.0-sdk-1.9.63.jar),详情参见源码说明部分。
二、源码说明
package appengine.util;@b@@b@import com.google.appengine.api.memcache.MemcacheService;@b@import com.google.appengine.api.memcache.MemcacheServiceFactory;@b@import com.google.apphosting.api.ApiProxy;@b@import com.google.apphosting.api.ApiProxy.Environment;@b@@b@public class MemcacheUtil@b@{@b@ static String version = ApiProxy.getCurrentEnvironment().getVersionId();@b@@b@ public static void delete(String key)@b@ {@b@ MemcacheServiceFactory.getMemcacheService().delete(version + ":" + key);@b@ }@b@@b@ public static void put(String key, Object object)@b@ {@b@ MemcacheServiceFactory.getMemcacheService().put(version + ":" + key, object);@b@ }@b@@b@ public static Object get(String key)@b@ {@b@ return MemcacheServiceFactory.getMemcacheService().get(version + ":" + key);@b@ }@b@@b@ public static <T> T get(String key, Class<T> clazz)@b@ throws ClassCastException@b@ {@b@ return MemcacheServiceFactory.getMemcacheService().get(version + ":" + key);@b@ }@b@}