|
|
@@ -1,11 +1,13 @@
|
|
1
|
1
|
package com.ruoyi.common.redis.service;
|
|
2
|
2
|
|
|
3
|
3
|
import java.util.Collection;
|
|
|
4
|
+import java.util.Iterator;
|
|
4
|
5
|
import java.util.List;
|
|
5
|
6
|
import java.util.Map;
|
|
6
|
7
|
import java.util.Set;
|
|
7
|
8
|
import java.util.concurrent.TimeUnit;
|
|
8
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
10
|
+import org.springframework.data.redis.core.BoundSetOperations;
|
|
9
|
11
|
import org.springframework.data.redis.core.HashOperations;
|
|
10
|
12
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
11
|
13
|
import org.springframework.data.redis.core.ValueOperations;
|
|
|
@@ -136,10 +138,15 @@ public class RedisService
|
|
136
|
138
|
* @param dataSet 缓存的数据
|
|
137
|
139
|
* @return 缓存数据的对象
|
|
138
|
140
|
*/
|
|
139
|
|
- public <T> long setCacheSet(final String key, final Set<T> dataSet)
|
|
|
141
|
+ public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
|
|
140
|
142
|
{
|
|
141
|
|
- Long count = redisTemplate.opsForSet().add(key, dataSet);
|
|
142
|
|
- return count == null ? 0 : count;
|
|
|
143
|
+ BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
|
|
144
|
+ Iterator<T> it = dataSet.iterator();
|
|
|
145
|
+ while (it.hasNext())
|
|
|
146
|
+ {
|
|
|
147
|
+ setOperation.add(it.next());
|
|
|
148
|
+ }
|
|
|
149
|
+ return setOperation;
|
|
143
|
150
|
}
|
|
144
|
151
|
|
|
145
|
152
|
/**
|