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

Merge pull request !138 from BecomeDream/N/A
This commit is contained in:
若依 2020-12-13 14:54:17 +08:00 committed by Gitee
commit 6800a12014
1 changed files with 8 additions and 3 deletions

View File

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