From 8d9de49fa0355a3f0af85171ede326ea18fea226 Mon Sep 17 00:00:00 2001 From: Parker Date: Wed, 3 Feb 2021 19:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/opsli/core/cache/local/CacheUtil.java | 8 +++---- .../org/opsli/plugins/redis/RedisPlugin.java | 23 +++++++++++++++++-- .../main/resources/config/ehcache-opsli.xml | 4 ++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/local/CacheUtil.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/local/CacheUtil.java index a704054..d7e17ed 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/local/CacheUtil.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/local/CacheUtil.java @@ -60,8 +60,8 @@ import static org.opsli.common.constants.OrderConstants.UTIL_ORDER; @Component public class CacheUtil { - /** 热点数据缓存时间 秒 */ - private static int TTL_HOT_DATA_TIME = 60000; + /** 热点数据缓存时间 秒 (6小时)*/ + private static int TTL_HOT_DATA_TIME = 21600; /** 空缓存时间 秒 */ private final static int TTL_NIL_DATA_TIME = 300; /** Redis插件 */ @@ -306,7 +306,7 @@ public class CacheUtil { } // 如果本地缓存找不到该缓存 则去远端缓存拉去缓存 - cacheJson = (JSONObject) redisPlugin.hGet(key, field); + cacheJson = (JSONObject) redisPlugin.hGet(cacheKey, field); if(cacheJson != null){ // 判读是否需要 存入本地EhCache if(isSaveLocal){ @@ -616,7 +616,7 @@ public class CacheUtil { Node ttlNode = expiryNodes.item(k); Node ttlValue = ttlNode.getFirstChild(); // 默认 60000秒 6小时 - TTL_HOT_DATA_TIME = Convert.toInt(ttlValue.getNodeValue(), 60000); + TTL_HOT_DATA_TIME = Convert.toInt(ttlValue.getNodeValue(), 21600); break; } } diff --git a/opsli-plugins/opsli-plugins-redis/src/main/java/org/opsli/plugins/redis/RedisPlugin.java b/opsli-plugins/opsli-plugins-redis/src/main/java/org/opsli/plugins/redis/RedisPlugin.java index 4d76e7f..fe2433a 100644 --- a/opsli-plugins/opsli-plugins-redis/src/main/java/org/opsli/plugins/redis/RedisPlugin.java +++ b/opsli-plugins/opsli-plugins-redis/src/main/java/org/opsli/plugins/redis/RedisPlugin.java @@ -924,6 +924,21 @@ public class RedisPlugin { return redisTemplate.opsForSet().add(key, values); } + /** + * set添加元素 + * + * @param key + * @param values + * @return + */ + public Long sPutAll(String key, Collection values) { + Object[] objects = {}; + if(values != null){ + objects = values.toArray(); + } + return redisTemplate.opsForSet().add(key, objects); + } + /** * set移除元素 * @@ -942,8 +957,12 @@ public class RedisPlugin { * @param values * @return */ - public Long sRemove(String key, Collection values) { - return redisTemplate.opsForSet().remove(key, values); + public Long sRemoveList(String key, Collection values) { + Object[] objects = {}; + if(values != null){ + objects = values.toArray(); + } + return redisTemplate.opsForSet().remove(key, objects); } diff --git a/opsli-starter/src/main/resources/config/ehcache-opsli.xml b/opsli-starter/src/main/resources/config/ehcache-opsli.xml index 9b11b5d..f288899 100644 --- a/opsli-starter/src/main/resources/config/ehcache-opsli.xml +++ b/opsli-starter/src/main/resources/config/ehcache-opsli.xml @@ -23,8 +23,8 @@ - - 60000 + + 21600