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

/**
 * Get the size of list stored at {@code key}.
 * <p>//  w w w .  jav a  2  s.  co m
 * See http://redis.io/commands/llen
 * 
 * @param key key
 * @return Long
 */
public Long lLen(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.lLen(key);
        }
    });
}

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

/**
 * Trim list at {@code key} to elements between {@code begin} and {@code end}.
 * <p>/*ww w  .j  ava2s .  co m*/
 * See http://redis.io/commands/ltrim
 * 
 * @param key key
 * @param begin begin
 * @param end end
 */
public static void lTrim(byte[] key, long begin, long end) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.lTrim(key, begin, end);
            return null;
        }
    });
}

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

/**
 * Get elements between {@code begin} and {@code end} from list at {@code key}.
 * <p>//from   ww  w.java  2 s  .c  o m
 * See http://redis.io/commands/lrange
 * 
 * @param key key
 * @param begin begin
 * @param end end
 * @return List<byte[]>
 */
public List<byte[]> lRange(byte[] key, long begin, long end) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.lRange(key, begin, end);
        }
    });
}

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

/**
 * Get element at {@code index} form list at {@code key}.
 * <p>//w w  w. j a v  a2 s.  c  om
 * See http://redis.io/commands/lindex
 * 
 * @param key key
 * @param index index
 * @return byte[]
 */
public static byte[] lIndex(byte[] key, long index) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.lIndex(key, index);
        }
    });
}

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

/**
 * Trim list at {@code key} to elements between {@code begin} and {@code end}.
 * <p>//from  ww w.j  a  v  a2  s . co  m
 * See http://redis.io/commands/ltrim
 * 
 * @param key key
 * @param begin begin
 * @param end end
 */
public void lTrim(byte[] key, long begin, long end) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.lTrim(key, begin, end);
            return null;
        }
    });
}

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

/**
 * Insert {@code value} {@link Position#BEFORE} or {@link Position#AFTER} existing {@code pivot} for {@code key}.
 * <p>//from  w w w  . j a v  a  2s .co  m
 * See http://redis.io/commands/linsert
 * 
 * @param key key
 * @param where where
 * @param pivot pivot
 * @param value value
 * @return Long
 */
public static Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.lInsert(key, where, pivot, value);
        }
    });
}

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

/**
 * Get element at {@code index} form list at {@code key}.
 * <p>//from  w w w.j  av a2  s .  c  o m
 * See http://redis.io/commands/lindex
 * 
 * @param key key
 * @param index index
 * @return byte[]
 */
public byte[] lIndex(byte[] key, long index) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.lIndex(key, index);
        }
    });
}

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

/**
 * Set the {@code value} list element at {@code index}.
 * <p>// www . ja  v  a 2  s.co  m
 * See http://redis.io/commands/lset
 * 
 * @param key key
 * @param index index
 * @param value value
 */
public static void lSet(byte[] key, long index, byte[] value) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.lSet(key, index, value);
            return null;
        }
    });
}

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

/**
 * Insert {@code value} {@link Position#BEFORE} or {@link Position#AFTER} existing {@code pivot} for {@code key}.
 * <p>/*from   w w  w.j  a  va2 s .c  om*/
 * See http://redis.io/commands/linsert
 * 
 * @param key key
 * @param where where
 * @param pivot pivot
 * @param value value
 * @return Long
 */
public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.lInsert(key, where, pivot, value);
        }
    });
}

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

/**
 * Removes the first {@code count} occurrences of {@code value} from the list stored at {@code key}.
 * <p>/*from  www. j  a  v  a  2s .  com*/
 * See http://redis.io/commands/lrem
 * 
 * @param key key
 * @param count count
 * @param value value
 * @return Long
 */
public static Long lRem(byte[] key, long count, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.lRem(key, count, value);
        }
    });
}