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

/**
 * 'Native' or 'raw' execution of the given command along-side the given arguments. The command is executed as is,
 * with as little 'interpretation' as possible - it is up to the caller to take care of any processing of arguments or
 * the result.//from  w  w w .  j  a va2s.  c o  m
 * 
 * @param command Command to execute
 * @param args Possible command arguments (may be null)
 * @return execution result.
 */
public Object execute(String command, byte[]... args) {
    return redisTemplate.execute(new RedisCallback<Object>() {
        @Override
        public Object doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.execute(command, args);
        }
    });
}

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

/**
 * Delete given {@code keys}./*from  w  w  w.  ja v  a2s.c  o  m*/
 * <p>
 * See http://redis.io/commands/del
 * 
 * @param keys keys
 * @return The number of keys that were removed.
 */
public static Long del(byte[]... keys) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.del(keys);
        }
    });
}

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

/**
 * Determine if given {@code key} exists.
 * <p>/*  w w  w .  j  av  a 2  s . c o  m*/
 * See http://redis.io/commands/exists
 * 
 * @param key key
 * @return Boolean
 */
public Boolean exists(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.exists(key);
        }
    });
}

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

/**
 * Determine the type stored at {@code key}.
 * <p>//w  w w. j a v  a 2s .  c o  m
 * See http://redis.io/commands/type
 * 
 * @param key key
 * @return DataType
 */
public static DataType type(byte[] key) {
    return redisTemplate.execute(new RedisCallback<DataType>() {
        @Override
        public DataType doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.type(key);
        }
    });
}

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

/**
 * Delete given {@code keys}./*from   w  ww .  j  av  a  2  s. com*/
 * <p>
 * See http://redis.io/commands/del
 * 
 * @param keys keys
 * @return The number of keys that were removed.
 */
public Long del(byte[]... keys) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.del(keys);
        }
    });
}

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

/**
 * Find all keys matching the given {@code pattern}.
 * <p>/*from  w ww.ja va  2  s  . c  om*/
 * See http://redis.io/commands/keys
 * 
 * @param pattern pattern
 * @return Set<byte[]>
 */
public static Set<byte[]> keys(byte[] pattern) {
    return redisTemplate.execute(new RedisCallback<Set<byte[]>>() {
        @Override
        public Set<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.keys(pattern);
        }
    });
}

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

/**
 * Determine the type stored at {@code key}.
 * <p>//  www. j  a v a2s .c o  m
 * See http://redis.io/commands/type
 * 
 * @param key key
 * @return DataType
 */
public DataType type(byte[] key) {
    return redisTemplate.execute(new RedisCallback<DataType>() {
        @Override
        public DataType doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.type(key);
        }
    });
}

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

/**
 * Use a {@link Cursor} to iterate over keys.
 * <p>//from   www. j a v a 2s . c  om
 * See http://redis.io/commands/scan
 * 
 * @param options options
 * @return Cursor<byte[]>
 * @since 1.4
 */
public static Cursor<byte[]> scan(ScanOptions options) {
    return redisTemplate.execute(new RedisCallback<Cursor<byte[]>>() {
        @Override
        public Cursor<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.scan(options);
        }
    });
}

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

/**
 * Find all keys matching the given {@code pattern}.
 * <p>// w ww  . j  a v a2 s . c  om
 * See http://redis.io/commands/keys
 * 
 * @param pattern pattern
 * @return Set<byte[]>
 */
public Set<byte[]> keys(byte[] pattern) {
    return redisTemplate.execute(new RedisCallback<Set<byte[]>>() {
        @Override
        public Set<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.keys(pattern);
        }
    });
}

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

/**
 * Return a random key from the keyspace.
 * <p>//from   ww w . ja  v a  2s.co  m
 * See http://redis.io/commands/randomkey
 * 
 * @return byte[]
 */
public static byte[] randomKey() {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.randomKey();
        }
    });
}