From ff979772fef6db55d0c2e32744af216ae3f45fe4 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 13 Dec 2020 17:08:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9Set=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=B5=8C=E5=A5=97=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/redis/service/RedisService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java index df9187751..4bf7f708b 100644 --- a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java +++ b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java @@ -1,11 +1,13 @@ package com.ruoyi.common.redis.service; 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 class RedisService * @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; } /**