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);

Source Link

Document

Count the number of set bits (population counting) in value stored at key .

Usage

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

/**
 * Count the number of set bits (population counting) in value stored at {@code key}.
 * <p>/* www  . ja  v a 2s.  c o m*/
 * See http://redis.io/commands/bitcount
 * 
 * @param key must not be {@literal null}.
 * @return Long
 */
public static Long bitCount(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bitCount(key);
        }
    });
}

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

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