diff --git a/src/main/java/com/ruoyi/framework/redis/RedisCache.java b/src/main/java/com/ruoyi/framework/redis/RedisCache.java index 2905a383..61572743 100644 --- a/src/main/java/com/ruoyi/framework/redis/RedisCache.java +++ b/src/main/java/com/ruoyi/framework/redis/RedisCache.java @@ -1,11 +1,13 @@ package com.ruoyi.framework.redis; import java.util.Collection; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.BoundSetOperations; import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; @@ -136,10 +138,15 @@ public List getCacheList(final String key) * @param dataSet 缓存的数据 * @return 缓存数据的对象 */ - public long setCacheSet(final String key, final Set dataSet) + public BoundSetOperations setCacheSet(final String key, final Set dataSet) { - Long count = redisTemplate.opsForSet().add(key, dataSet); - return count == null ? 0 : count; + BoundSetOperations setOperation = redisTemplate.boundSetOps(key); + Iterator it = dataSet.iterator(); + while (it.hasNext()) + { + setOperation.add(it.next()); + } + return setOperation; } /**