org.springframework.data.redis.core.BoundSetOperations Java Examples

The following examples show how to use org.springframework.data.redis.core.BoundSetOperations. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostScoreRefreshJob.java    From MyCommunity with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    String redisKey = RedisKeyUtil.getPostScoreKey();
    BoundSetOperations operations = redisTemplate.boundSetOps(redisKey);

    // 例如半夜时间段没人访问网站帖子,就不用刷新了
    if (operations.size() == 0) {
        logger.info("[任务取消] 没有需要刷新的帖子!");
        return;
    }

    // 统计每次刷新的时间,将来如果出现很卡的现象可以分析
    logger.info("[任务开始] 正在刷新帖子分数: " + operations.size());
    while (operations.size() > 0) {
        this.refresh((Integer) operations.pop());
    }
    logger.info("[任务结束] 帖子分数刷新完毕!");
}
 
Example #2
Source File: RedisDeadQueue.java    From Milkomeda with MIT License 5 votes vote down vote up
@Override
public List<DelayJob> pop(long count) {
    BoundSetOperations<String, String> deadQueue = getDeadQueue(this.deadQueueKey);
    Set<String> members = deadQueue.distinctRandomMembers(count);
    if (CollectionUtils.isEmpty(members)) {
        return null;
    }
    deadQueue.remove(members.toArray());
    return members.stream().map(s -> JSONUtil.parse(s, DelayJob.class)).collect(Collectors.toList());
}
 
Example #3
Source File: RedisCache.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 缓存Set
 *
 * @param key 缓存键值
 * @param dataSet 缓存的数据
 * @return 缓存数据的对象
 */
public <T> BoundSetOperations<String, T> setCacheSet(String key, Set<T> dataSet)
{
    BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
    Iterator<T> it = dataSet.iterator();
    while (it.hasNext())
    {
        setOperation.add(it.next());
    }
    return setOperation;
}
 
Example #4
Source File: RedisCache.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 获得缓存的set
 *
 * @param key
 * @return
 */
public <T> Set<T> getCacheSet(String key)
{
    Set<T> dataSet = new HashSet<T>();
    BoundSetOperations<String, T> operation = redisTemplate.boundSetOps(key);
    dataSet = operation.members();
    return dataSet;
}
 
Example #5
Source File: RedisCacheService.java    From DimpleBlog with Apache License 2.0 5 votes vote down vote up
/**
 * 缓存Set
 *
 * @param key     缓存键值
 * @param dataSet 缓存的数据
 * @return 缓存数据的对象
 */
public <T> BoundSetOperations<String, T> setCacheSet(String key, Set<T> dataSet) {
    BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
    Iterator<T> it = dataSet.iterator();
    while (it.hasNext()) {
        setOperation.add(it.next());
    }
    return setOperation;
}
 
Example #6
Source File: RedisCacheService.java    From DimpleBlog with Apache License 2.0 5 votes vote down vote up
/**
 * 获得缓存的set
 *
 * @param key
 * @return
 */
public <T> Set<T> getCacheSet(String key) {
    Set<T> dataSet = new HashSet<>();
    BoundSetOperations<String, T> operation = redisTemplate.boundSetOps(key);
    Long size = operation.size();
    for (int i = 0; i < size; i++) {
        dataSet.add(operation.pop());
    }
    return dataSet;
}
 
Example #7
Source File: RedisListenerContainerTaskExecutorITests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void testRedisDelEventsAreDispatchedInSessionTaskExecutor() throws InterruptedException {
	BoundSetOperations<Object, Object> ops = this.redis
			.boundSetOps("spring:session:RedisListenerContainerTaskExecutorITests:expirations:dummy");
	ops.add("value");
	ops.remove("value");
	assertThat(this.executor.taskDispatched()).isTrue();

}
 
Example #8
Source File: RedisDeadQueue.java    From Milkomeda with MIT License 4 votes vote down vote up
private BoundSetOperations<String, String> getDeadQueue(String key) {
    return redisTemplate.boundSetOps(key);
}
 
Example #9
Source File: MyRedisTemplate.java    From redis-admin with Apache License 2.0 4 votes vote down vote up
@Override
public BoundSetOperations<K, V> boundSetOps(K key) {
	throw new MethodNotSupportException("myRedisTemplate not support this method : boundSetOps(K key) , please use opsForXX");
	//return new DefaultBoundSetOperations<K, V>(key, this);
}