org.springframework.data.redis.support.atomic.RedisAtomicInteger Java Examples

The following examples show how to use org.springframework.data.redis.support.atomic.RedisAtomicInteger. 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: SequenceServiceImpl.java    From sctalk with Apache License 2.0 6 votes vote down vote up
@Override
public Integer addAndGetInteger(String key, int step) {
    RedisAtomicInteger counter = 
            new RedisAtomicInteger(key, redisTemplate.getConnectionFactory()); 
    Integer sequence =  counter.addAndGet(step);
    
    return sequence; 
}
 
Example #2
Source File: LimiterController.java    From SpringBootLearn with Apache License 2.0 5 votes vote down vote up
@RateLimit(key = "test", time = 10, count = 5)
@GetMapping("/test")
public String luaLimiter() {
    // 简单测试方法
    RedisAtomicInteger entityIdCounter = new RedisAtomicInteger("counter", redisTemplate.getConnectionFactory());
    String date = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
    return date + " 累计访问次数:" + entityIdCounter.getAndIncrement();
}
 
Example #3
Source File: HerokuRedisConfig.java    From spring-redis-websocket with Apache License 2.0 4 votes vote down vote up
@Bean
RedisAtomicInteger chatMessageCounter(RedisConnectionFactory redisConnectionFactory) {
	return new RedisAtomicInteger(MESSAGE_COUNTER_KEY, redisConnectionFactory);
}
 
Example #4
Source File: RedisConfig.java    From spring-redis-websocket with Apache License 2.0 4 votes vote down vote up
@Bean
RedisAtomicInteger chatMessageCounter(RedisConnectionFactory redisConnectionFactory) {
	return new RedisAtomicInteger(MESSAGE_COUNTER_KEY, redisConnectionFactory);
}
 
Example #5
Source File: RedisChatMessagePublisher.java    From spring-redis-websocket with Apache License 2.0 4 votes vote down vote up
public RedisChatMessagePublisher(ReactiveStringRedisTemplate reactiveStringRedisTemplate, RedisAtomicInteger chatMessageCounter, RedisAtomicLong activeUserCounter, ObjectMapper objectMapper) {
	this.reactiveStringRedisTemplate = reactiveStringRedisTemplate;
	this.chatMessageCounter = chatMessageCounter;
	this.activeUserCounter = activeUserCounter;
	this.objectMapper = objectMapper;
}