...
|
...
|
@@ -74,32 +74,23 @@ public class RedisListCache { |
|
|
|
|
|
}
|
|
|
|
|
|
public <T> void rightPushAll(String key,Collection<T> values, long timeout, TimeUnit unit) {
|
|
|
logger.debug("Enter rightPushAll redis list. key is {}, value is {}, timeout is {}, unit is {}", key, values, timeout, unit);
|
|
|
public <T> void rightPushAll(String key,String value, long timeout, TimeUnit unit) {
|
|
|
logger.debug("Enter rightPushAll redis list. key is {}, value is {}, timeout is {}, unit is {}", key, value, timeout, unit);
|
|
|
// 如果是空列表,直接返回
|
|
|
if (CollectionUtils.isEmpty(values)) {
|
|
|
if (StringUtils.isEmpty(value)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
String cacheKey = key;
|
|
|
// 如果获取的key为空,则说明缓存开关是关闭的
|
|
|
if (StringUtils.isEmpty(cacheKey)) {
|
|
|
if (StringUtils.isEmpty(key)) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
Collection<String> strValues = new ArrayList<String>();
|
|
|
for (T t : values) {
|
|
|
String strValue = CacheKeyHelper.value2String(t);
|
|
|
if (StringUtils.isEmpty(strValue)) {
|
|
|
continue;
|
|
|
}
|
|
|
strValues.add(strValue);
|
|
|
}
|
|
|
yhListOperations.rightPushAll(cacheKey, strValues);
|
|
|
yHRedisTemplate.longExpire(cacheKey, timeout, unit);
|
|
|
yhListOperations.rightPushAll(key, value);
|
|
|
yHRedisTemplate.longExpire(key, timeout, unit);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("rightPushAll redis list operation failed. key is {}", cacheKey, e);
|
|
|
logger.warn("rightPushAll redis list operation failed. key is {}", key, e);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|