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

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

Introduction

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

Prototype

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

Source Link

Document

Get a substring of value of key between start and end .

Usage

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

public String get(K key, final long start, final long end) {
    final byte[] rawKey = rawKey(key);

    byte[] rawReturn = execute(new RedisCallback<byte[]>() {

        public byte[] doInRedis(RedisConnection connection) {
            connection.select(dbIndex);//from w ww .  j  a  va2s  . c om
            return connection.getRange(rawKey, start, end);
        }
    }, true);

    return deserializeString(rawReturn);
}

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

/**
 * Get a substring of value of {@code key} between {@code begin} and {@code end}.
 * <p>/* w w w  .j a v a2  s.  co  m*/
 * See http://redis.io/commands/getrange
 * 
 * @param key must not be {@literal null}.
 * @param begin begin
 * @param end end
 * @return byte[]
 */
public static 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.RedisHelper.java

/**
 * Get a substring of value of {@code key} between {@code begin} and {@code end}.
 * <p>//from ww w  .j  a va  2 s.c  om
 * 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);
        }
    });
}