作者 BecomeDream
提交者 Gitee

修改Set可能导致嵌套的问题

@@ -136,10 +136,15 @@ public class RedisCache @@ -136,10 +136,15 @@ public class RedisCache
136 * @param dataSet 缓存的数据 136 * @param dataSet 缓存的数据
137 * @return 缓存数据的对象 137 * @return 缓存数据的对象
138 */ 138 */
139 - public <T> long setCacheSet(final String key, final Set<T> dataSet) 139 + public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
140 { 140 {
141 - Long count = redisTemplate.opsForSet().add(key, dataSet);  
142 - return count == null ? 0 : count; 141 + BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
  142 + Iterator<T> it = dataSet.iterator();
  143 + while (it.hasNext())
  144 + {
  145 + setOperation.add(it.next());
  146 + }
  147 + return setOperation;
143 } 148 }
144 149
145 /** 150 /**