工具类优化

v1.4.1
Parker 5 years ago
parent d1a95d6a76
commit 8d9de49fa0

@ -60,8 +60,8 @@ import static org.opsli.common.constants.OrderConstants.UTIL_ORDER;
@Component @Component
public class CacheUtil { public class CacheUtil {
/** 热点数据缓存时间 秒 */ /** 热点数据缓存时间 秒 (6小时)*/
private static int TTL_HOT_DATA_TIME = 60000; private static int TTL_HOT_DATA_TIME = 21600;
/** 空缓存时间 秒 */ /** 空缓存时间 秒 */
private final static int TTL_NIL_DATA_TIME = 300; private final static int TTL_NIL_DATA_TIME = 300;
/** Redis插件 */ /** Redis插件 */
@ -306,7 +306,7 @@ public class CacheUtil {
} }
// 如果本地缓存找不到该缓存 则去远端缓存拉去缓存 // 如果本地缓存找不到该缓存 则去远端缓存拉去缓存
cacheJson = (JSONObject) redisPlugin.hGet(key, field); cacheJson = (JSONObject) redisPlugin.hGet(cacheKey, field);
if(cacheJson != null){ if(cacheJson != null){
// 判读是否需要 存入本地EhCache // 判读是否需要 存入本地EhCache
if(isSaveLocal){ if(isSaveLocal){
@ -616,7 +616,7 @@ public class CacheUtil {
Node ttlNode = expiryNodes.item(k); Node ttlNode = expiryNodes.item(k);
Node ttlValue = ttlNode.getFirstChild(); Node ttlValue = ttlNode.getFirstChild();
// 默认 60000秒 6小时 // 默认 60000秒 6小时
TTL_HOT_DATA_TIME = Convert.toInt(ttlValue.getNodeValue(), 60000); TTL_HOT_DATA_TIME = Convert.toInt(ttlValue.getNodeValue(), 21600);
break; break;
} }
} }

@ -924,6 +924,21 @@ public class RedisPlugin {
return redisTemplate.opsForSet().add(key, values); return redisTemplate.opsForSet().add(key, values);
} }
/**
* set
*
* @param key
* @param values
* @return
*/
public Long sPutAll(String key, Collection<Object> values) {
Object[] objects = {};
if(values != null){
objects = values.toArray();
}
return redisTemplate.opsForSet().add(key, objects);
}
/** /**
* set * set
* *
@ -942,8 +957,12 @@ public class RedisPlugin {
* @param values * @param values
* @return * @return
*/ */
public Long sRemove(String key, Collection<Object> values) { public Long sRemoveList(String key, Collection<Object> values) {
return redisTemplate.opsForSet().remove(key, values); Object[] objects = {};
if(values != null){
objects = values.toArray();
}
return redisTemplate.opsForSet().remove(key, objects);
} }

@ -23,8 +23,8 @@
<cache alias="timed" uses-template="opsliDefaults"> <cache alias="timed" uses-template="opsliDefaults">
<!--缓存到期配置--> <!--缓存到期配置-->
<expiry> <expiry>
<!-- 只允许配秒 --> <!-- 只允许配秒 默认 21600秒6小时 -->
<ttl unit="seconds">60000</ttl> <ttl unit="seconds">21600</ttl>
</expiry> </expiry>
</cache> </cache>

Loading…
Cancel
Save