diff --git a/com.creditease.uav.cache.redis/pom.xml b/com.creditease.uav.cache.redis/pom.xml
index 02e4532d..67c6b05c 100644
--- a/com.creditease.uav.cache.redis/pom.xml
+++ b/com.creditease.uav.cache.redis/pom.xml
@@ -37,6 +37,42 @@
commons-logging
commons-logging
1.2
-
+
+
+ io.netty
+ netty-all
+ 4.1.11.Final
+
+
+ io.lettuce
+ lettuce-core
+ 5.0.5.RELEASE
+
+
+ io.netty
+ netty-common
+
+
+ io.netty
+ netty-transport
+
+
+ io.netty
+ netty-buffer
+
+
+ io.netty
+ netty-resolver
+
+
+ io.netty
+ netty-handler
+
+
+ io.netty
+ netty-codec
+
+
+
\ No newline at end of file
diff --git a/com.creditease.uav.cache.redis/src/main/java/com/creditease/uav/cache/api/CacheManager.java b/com.creditease.uav.cache.redis/src/main/java/com/creditease/uav/cache/api/CacheManager.java
index 828d422a..f073b02e 100644
--- a/com.creditease.uav.cache.redis/src/main/java/com/creditease/uav/cache/api/CacheManager.java
+++ b/com.creditease.uav.cache.redis/src/main/java/com/creditease/uav/cache/api/CacheManager.java
@@ -430,10 +430,20 @@ public static void build(String cacheServerAddress, int minConcurrent, int maxCo
private CacheService service;
private L1Cache l1cache;
-
+
+ private static CacheClientMode clientMode;
+
protected CacheManager(String cacheServerAddress, int minConcurrent, int maxConcurrent, int queueSize,
String password) {
- service = CacheFactory.instance().createCacheService(CacheClientMode.AREDIS, cacheServerAddress, minConcurrent,
+
+ if (cacheServerAddress.contains(",")) {
+ clientMode = CacheClientMode.LETTUCE;
+ }
+ else {
+ clientMode = CacheClientMode.AREDIS;
+ }
+
+ service = CacheFactory.instance().createCacheService(clientMode, cacheServerAddress, minConcurrent,
maxConcurrent, queueSize, password);
l1cache = new L1Cache();
}
@@ -1239,7 +1249,8 @@ public void putHash(String region, String key, Map fieldValues,
* @param fieldNames
* @return
*/
- public Map getHash(String region, String key, String... fieldNames) {
+ @SuppressWarnings("unchecked")
+ public Map getHash(String region, String key, String... fieldNames) {
if (null == fieldNames) {
Collections.emptyMap();
@@ -1253,8 +1264,13 @@ public Map getHash(String region, String key, String... fieldNam
if (null != results && results.length > 0) {
- Map value = genHMGetResults(fieldNames, results);
-
+ Map value = new HashMap();
+ if (clientMode.equals(CacheClientMode.LETTUCE) && results[0] instanceof Map) {
+ value = (Map) results[0];
+ }
+ else {
+ value = genHMGetResults(fieldNames, results);
+ }
return value;
}
@@ -1321,8 +1337,13 @@ public Map getHashAll(String region, String key) {
if (null != results && results.length > 0) {
- Map value = genHMGetResults(null, results);
-
+ Map value = new HashMap();
+ if (clientMode.equals(CacheClientMode.LETTUCE) && results[0] instanceof Map) {
+ value = (Map) results[0];
+ }
+ else {
+ value = genHMGetResults(null, results);
+ }
this.l1cache.put(rkey, value);
return value;
@@ -1362,7 +1383,14 @@ public void getHashAll(String region, String key, AsyncCacheCallback