Example usage for org.springframework.data.redis.connection RedisConnection bitCount

List of usage examples for org.springframework.data.redis.connection RedisConnection bitCount

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection RedisConnection bitCount.

Prototype

@Nullable
Long bitCount(byte[] key, long start, long end);

Source Link

Document

Count the number of set bits (population counting) of value stored at key between start and end .

Usage

From source file:com.zxy.commons.cache.RedisUtils.java

/**
 * Count the number of set bits (population counting) of value stored at {@code key} between {@code begin} and
 * {@code end}.//  w w w  .jav a  2s.com
 * <p>
 * See http://redis.io/commands/bitcount
 * 
 * @param key must not be {@literal null}.
 * @param begin begin
 * @param end end
 * @return Long
 */
public static Long bitCount(byte[] key, long begin, long end) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bitCount(key, begin, end);
        }
    });
}

From source file:com.zxy.commons.cache.RedisHelper.java

/**
 * Count the number of set bits (population counting) of value stored at {@code key} between {@code begin} and
 * {@code end}.//from   w ww.j a  va  2  s. co m
 * <p>
 * See http://redis.io/commands/bitcount
 * 
 * @param key must not be {@literal null}.
 * @param begin begin
 * @param end end
 * @return Long
 */
public Long bitCount(byte[] key, long begin, long end) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bitCount(key, begin, end);
        }
    });
}