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 all elements of set at {@code key}.
 * <p>/*from ww  w. ja v  a 2 s  .  c  om*/
 * See http://redis.io/commands/smembers
 * 
 * @param key key
 * @return Set<byte[]>
 */
public Set<byte[]> sMembers(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Set<byte[]>>() {
        @Override
        public Set<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sMembers(key);
        }
    });
}

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

/**
 * Get random element from set at {@code key}.
 * <p>/*w  w  w  . ja  v a  2  s. com*/
 * See http://redis.io/commands/srandmember
 * 
 * @param key key
 * @return byte[]
 */
public byte[] sRandMember(byte[] key) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sRandMember(key);
        }
    });
}

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

/**
 * Get {@code count} random elements from set at {@code key}.
 * <p>/* ww w.  ja v a 2s  .  c  om*/
 * See http://redis.io/commands/srandmember
 * 
 * @param key key
 * @param count count
 * @return List<byte[]>
 */
public static List<byte[]> sRandMember(byte[] key, long count) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sRandMember(key, count);
        }
    });
}

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

/**
 * Get {@code count} random elements from set at {@code key}.
 * <p>/*from  www.  ja  va 2 s .c o m*/
 * See http://redis.io/commands/srandmember
 * 
 * @param key key
 * @param count count
 * @return List<byte[]>
 */
public List<byte[]> sRandMember(byte[] key, long count) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sRandMember(key, count);
        }
    });
}

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

/**
 * Use a {@link Cursor} to iterate over elements in set at {@code key}.
 * <p>// w  w  w. j av a 2 s.c om
 * See http://redis.io/commands/scan
 * 
 * @since 1.4
 * @param key key
 * @param options options
 * @return Cursor<byte[]>
 */
public static Cursor<byte[]> sScan(byte[] key, ScanOptions options) {
    return redisTemplate.execute(new RedisCallback<Cursor<byte[]>>() {
        @Override
        public Cursor<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sScan(key, options);
        }
    });
}

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

/**
 * Use a {@link Cursor} to iterate over elements in set at {@code key}.
 * <p>//  w  w  w  .ja  va  2 s.com
 * See http://redis.io/commands/scan
 * 
 * @since 1.4
 * @param key key
 * @param options options
 * @return Cursor<byte[]>
 */
public Cursor<byte[]> sScan(byte[] key, ScanOptions options) {
    return redisTemplate.execute(new RedisCallback<Cursor<byte[]>>() {
        @Override
        public Cursor<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sScan(key, options);
        }
    });
}

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

/**
 * Add {@code value} to a sorted set at {@code key}, or update its {@code score} if it already exists.
 * <p>/*from w w w.  j a v a2 s .  com*/
 * See http://redis.io/commands/zadd
 * 
 * @param key key
 * @param score score
 * @param value value
 * @return Boolean
 */
public static Boolean zAdd(byte[] key, double score, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zAdd(key, score, value);
        }
    });
}

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

/**
 * Add {@code value} to a sorted set at {@code key}, or update its {@code score} if it already exists.
 * <p>/*w w  w  .  jav a  2  s . c o  m*/
 * See http://redis.io/commands/zadd
 * 
 * @param key key
 * @param score score
 * @param value value
 * @return Boolean
 */
public Boolean zAdd(byte[] key, double score, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zAdd(key, score, value);
        }
    });
}

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

/**
 * Add {@code tuples} to a sorted set at {@code key}, or update its {@code score} if it already exists.
 * <p>//from   www  .  j a  v  a  2  s .co m
 * See http://redis.io/commands/zadd
 * 
 * @param key key
 * @param tuples tuples
 * @return Long
 */
public static Long zAdd(byte[] key, Set<Tuple> tuples) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zAdd(key, tuples);
        }
    });
}

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

/**
 * Add {@code tuples} to a sorted set at {@code key}, or update its {@code score} if it already exists.
 * <p>//  www .j  a v  a 2 s.co  m
 * See http://redis.io/commands/zadd
 * 
 * @param key key
 * @param tuples tuples
 * @return Long
 */
public Long zAdd(byte[] key, Set<Tuple> tuples) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.zAdd(key, tuples);
        }
    });
}