Example usage for org.springframework.data.redis.core RedisCallback RedisCallback

List of usage examples for org.springframework.data.redis.core RedisCallback RedisCallback

Introduction

In this page you can find the example usage for org.springframework.data.redis.core RedisCallback RedisCallback.

Prototype

RedisCallback

Source Link

Usage

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

/**
 * Append a {@code value} to {@code key}.
 * <p>/*from  w  w w  .j  a  va 2 s.  c  om*/
 * See http://redis.io/commands/append
 * 
 * @param key must not be {@literal null}.
 * @param value value
 * @return Long
 */
public Long append(byte[] key, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.append(key, value);
        }
    });
}

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

/**
 * Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}.
 * <p>//w w  w.  j  ava  2 s .  c o  m
 * See http://redis.io/commands/setrange
 * 
 * @param key must not be {@literal null}.
 * @param value value
 * @param offset offset
 */
public static void setRange(byte[] key, byte[] value, long offset) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.setRange(key, value, offset);
            return null;
        }
    });
}

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

/**
 * Get a substring of value of {@code key} between {@code begin} and {@code end}.
 * <p>/* w w w.j a  v  a  2 s. c  o  m*/
 * See http://redis.io/commands/getrange
 * 
 * @param key must not be {@literal null}.
 * @param begin begin
 * @param end end
 * @return byte[]
 */
public byte[] getRange(byte[] key, long begin, long end) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.getRange(key, begin, end);
        }
    });
}

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

/**
 * Get the bit value at {@code offset} of value at {@code key}.
 * <p>// w w  w  .j  a va2 s  . co m
 * See http://redis.io/commands/getbit
 * 
 * @param key must not be {@literal null}.
 * @param offset offset
 * @return Boolean
 */
public static Boolean getBit(byte[] key, long offset) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.getBit(key, offset);
        }
    });
}

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

/**
 * Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}.
 * <p>/*from  w  w  w . j  a  v a 2 s  .  c  o  m*/
 * See http://redis.io/commands/setrange
 * 
 * @param key must not be {@literal null}.
 * @param value value
 * @param offset offset
 */
public void setRange(byte[] key, byte[] value, long offset) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.setRange(key, value, offset);
            return null;
        }
    });
}

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 a va2  s  . co  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

/**
 * Get the bit value at {@code offset} of value at {@code key}.
 * <p>/* www .  ja  v  a2  s  . c  om*/
 * See http://redis.io/commands/getbit
 * 
 * @param key must not be {@literal null}.
 * @param offset offset
 * @return Boolean
 */
public Boolean getBit(byte[] key, long offset) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.getBit(key, offset);
        }
    });
}

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

/**
 * Count the number of set bits (population counting) in value stored at {@code key}.
 * <p>/*from  ww  w . j a  v a2  s.  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

/**
 * Sets the bit at {@code offset} in value stored at {@code key}.
 * <p>// ww w .  ja v  a 2  s.c om
 * 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);
        }
    });
}

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}./*from  w  w w .jav  a  2s.c om*/
 * <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);
        }
    });
}