Skip to content

Commit

Permalink
修改Set可能导致嵌套的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Dec 13, 2020
1 parent a498e00 commit e5c7764
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/ruoyi/framework/redis/RedisCache.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -136,10 +138,15 @@ public <T> List<T> getCacheList(final String key)
* @param dataSet 缓存的数据
* @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);
return count == null ? 0 : count;
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
Iterator<T> it = dataSet.iterator();
while (it.hasNext())
{
setOperation.add(it.next());
}
return setOperation;
}

/**
Expand Down

0 comments on commit e5c7764

Please sign in to comment.