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

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

Introduction

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

Prototype

@Nullable
Boolean setBit(byte[] key, long offset, boolean value);

Source Link

Document

Sets the bit at offset in value stored at key .

Usage

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

/**
 * Sets the bit at {@code offset} in value stored at {@code key}.
 * <p>/*from  w w w. j av  a  2s.  c o  m*/
 * See http://redis.io/commands/setbit
 * 
 * @param key must not be {@literal null}.
 * @param offset offset
 * @param value value
 * @return the original bit value stored at {@code offset}.
 */
public static Boolean setBit(byte[] key, long offset, boolean value) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.setBit(key, offset, value);
        }
    });
}

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

/**
 * Sets the bit at {@code offset} in value stored at {@code key}.
 * <p>/*w  ww  . j  a v a2  s  .c  o m*/
 * See http://redis.io/commands/setbit
 * 
 * @param key must not be {@literal null}.
 * @param offset offset
 * @param value value
 * @return the original bit value stored at {@code offset}.
 */
public Boolean setBit(byte[] key, long offset, boolean value) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.setBit(key, offset, value);
        }
    });
}