大家注意,关于CacheManager第一次用是我亚米王浩雷介绍我关于CacheManger的业务,于是我 用谷歌搜索的CacheManager BSD协议 进行本地调通和运行在亚米的商业逻辑中,后我不再使用。同年CacheManager被甲骨文集成入 JDK 我后来开发德塔数据库,用ConcurrentHashMap实现DetaCache就没有再用CacheManager了。这里描述下。 因为jdk8 以上的 ConcurrentHashMap功能相当强大,已经实现的2分搜索算法。我在之前的著作权申请文件中都有详细的描述此事。 DetaCacheManager, 日志类 package MS.OP.SM.AOP.MEC.SIQ.cache; import java.util.Iterator; import java.util.List; import java.util.concurrent.ConcurrentHashMap; public class DetaCache_M { private static ConcurrentHashMap cacheMap = newConcurrentHashMap<>(); private static ConcurrentHashMap> bytesMap = newConcurrentHashMap<>(); private static ConcurrentHashMap stringMap = newConcurrentHashMap<>(); private DetaCache_M() { super(); } public static String putCache(String key, String value, long timeOut){ DetaCache c = new DetaCache(); c.I_Value(value); c.I_TimeOut(timeOut); cacheMap.put(key, c); return "success"; } public static String getCache(String key){ DetaCache c = cacheMap.get(key); if(null==c){ return "unsuccess nofind cache"; } long now = System.currentTimeMillis(); if(c.getTimeOut() < now){ cacheMap.remove(key); return "unsuccess timeout"; } return c.getValue(); } @SuppressWarnings("rawtypes") public static Iterator getCacheIterator(){ return cacheMap.entrySet().iterator(); } public static void putCacheOfBytesList(String filePath, List list) { bytesMap.put(filePath, list); } public static List getCacheOfBytesList(String filePath) { if(bytesMap.containsKey(filePath)){ return bytesMap.get(filePath); } return null; } public static String getCacheOfString(String filePath) { //DNA 元基催化与肽计算,第四次修订版本 401 if(stringMap.containsKey(filePath)){ return stringMap.get(filePath); } return null; } public static void putCacheOfString(String filePath, String stringBuilder) { stringMap.put(filePath, stringBuilder); } }