api-gateway-engine知识点(2)
2021-04-30 21:26
标签:shm get col 知识点 通过 getc info final import GroupVersion实现engine本地缓存 package com.inspur.cloud.apigw.engine.cache; import java.util.Map; import redis.clients.jedis.Jedis; public class GroupVersionCache { private static ConcurrentHashMap private GroupVersionCache() { } // 初始化redis中的Frtkey到本地cache中 // 在本地缓存中,通过groupCode和versionCode获取VersionInfo // 版本上线时,向engine本地中增加绑定关系缓存 // 下线时,删除本地缓存中的某条数据 } 为什么要用 conCurrentHashMap?Map或者HashMap也可以吧? api-gateway-engine知识点(2) 标签:shm get col 知识点 通过 getc info final import 原文地址:http://www.cnblogs.com/myfrank/p/7800745.html
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import com.inspur.cloud.apigw.engine.common.RedisCachePrefix;
import com.inspur.cloud.apigw.engine.common.RedisConnectionPool;
public static void initCache() throws Exception {
Jedis jedis = RedisConnectionPool.getConnection();
try {
Set
for (String key : keys) {
ConcurrentHashMap
Map
concurrentHashMap.putAll(value);
cache.put(key, concurrentHashMap);
}
} catch (Exception e) {
throw e;
} finally {
jedis.close();
}
}
public static ConcurrentHashMap
throws Exception {
try {
String grpVersionKey = RedisCachePrefix.getApiGrpVerKey(groupCode, versionCode);
return cache.get(grpVersionKey);
} catch (Exception e) {
throw e;
}
}
public static void addVersionInfoToCache(String messageKey, Map
try {
ConcurrentHashMap
concurrentHashMap.putAll(map);
cache.put(messageKey, concurrentHashMap);
} catch (Exception e) {
throw e;
}
}
public static void deleteCacheBykey(String messageKey) throws Exception {
try {
cache.remove(messageKey);
} catch (Exception e) {
throw e;
}
}
上一篇:C#委托事件随笔
文章标题:api-gateway-engine知识点(2)
文章链接:http://soscw.com/index.php/essay/80561.html