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

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

Introduction

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

Prototype

void setRange(byte[] key, byte[] value, long offset);

Source Link

Document

Overwrite parts of key starting at the specified offset with given value .

Usage

From source file:com.mauersu.util.redis.DefaultValueOperations.java

public void set(K key, final V value, final long offset) {
    final byte[] rawKey = rawKey(key);
    final byte[] rawValue = rawValue(value);

    execute(new RedisCallback<Object>() {

        public Object doInRedis(RedisConnection connection) {
            connection.select(dbIndex);/*from w w w .ja  v a 2  s . c  o  m*/
            connection.setRange(rawKey, rawValue, offset);
            return null;
        }
    }, true);
}

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  a  v a 2 s .c  om*/
 * 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

/**
 * Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}.
 * <p>/*from   w  w  w  .  ja  v a  2s  .  com*/
 * 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;
        }
    });
}