...
|
...
|
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
...
|
...
|
@@ -73,10 +74,10 @@ public class RedisListCache { |
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
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);
|
|
|
// 如果是空列表,直接返回
|
|
|
if (StringUtils.isEmpty(value)) {
|
|
|
if (CollectionUtils.isEmpty(values)) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -85,8 +86,15 @@ public class RedisListCache { |
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
yhListOperations.rightPushAll(key, value);
|
|
|
yHRedisTemplate.longExpire(key, timeout, unit);
|
|
|
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(key, strValues);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("rightPushAll redis list operation failed. key is {}", key, e);
|
...
|
...
|
|