Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

How to use Redis command "bitcount" in java

$
0
0

I am trying to use redis bitmap to save online user, use command "bitcount onlineUser" to count the number of online user.I use RedisTemplate to deal with redis. But I can't find any API in RedisTemplate to execute command "bitcount'.How can I execute command "bitcount" in java? Any help will be appreciated.

 @Override    public Boolean saveOnlineUser(Long userId) {        ValueOperations<String,Object> ops = redisTemplate.opsForValue();        return ops.setBit("onlineUser",userId,true);    }    @Override    public Integer getOnlineUser() {        //I want to use Redis command "bitcount 'onlineUser'" here to count the number of online users        return redisTemplate.opsForValue().;    }

Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>