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

/**
 * Count the number of set bits (population counting) in value stored at {@code key}.
 * <p>/*from   ww w.j av a2s .  c  o  m*/
 * See http://redis.io/commands/bitcount
 * 
 * @param key must not be {@literal null}.
 * @return Long
 */
public Long bitCount(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bitCount(key);
        }
    });
}

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

/**
 * Perform bitwise operations between strings.
 * <p>//from  w  w w  .  java  2  s. c o  m
 * See http://redis.io/commands/bitop
 * 
 * @param op op
 * @param destination destination
 * @param keys keys
 * @return Long
 */
public static Long bitOp(BitOperation op, byte[] destination, byte[]... keys) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bitOp(op, destination, keys);
        }
    });
}

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

/**
 * Count the number of set bits (population counting) of value stored at {@code key} between {@code begin} and
 * {@code end}.//w w w .ja v  a2 s. c o m
 * <p>
 * See http://redis.io/commands/bitcount
 * 
 * @param key must not be {@literal null}.
 * @param begin begin
 * @param end end
 * @return Long
 */
public Long bitCount(byte[] key, long begin, long end) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bitCount(key, begin, end);
        }
    });
}

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

/**
 * Get the length of the value stored at {@code key}.
 * <p>//w w  w .j  ava2 s .co  m
 * See http://redis.io/commands/strlen
 * 
 * @param key must not be {@literal null}.
 * @return Long
 */
public static Long strLen(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.strLen(key);
        }
    });
}

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

/**
 * Perform bitwise operations between strings.
 * <p>//from   w  ww  .  j  av  a  2s . c  o  m
 * See http://redis.io/commands/bitop
 * 
 * @param op op
 * @param destination destination
 * @param keys keys
 * @return Long
 */
public Long bitOp(BitOperation op, byte[] destination, byte[]... keys) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bitOp(op, destination, keys);
        }
    });
}

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

/**
 * Expire key for seconds/* www  .ja  va  2s . c o  m*/
 * <p>
 * See http://redis.io/commands/strlen
 * 
 * @param key must not be {@literal null}.
 * @param seconds seconds time
 * @return Long
 */
public static Boolean expire(byte[] key, int seconds) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.expire(key, seconds);
        }
    });
}

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

/**
 * Get the length of the value stored at {@code key}.
 * <p>//from   w  ww .j  a v  a  2 s. c o m
 * See http://redis.io/commands/strlen
 * 
 * @param key must not be {@literal null}.
 * @return Long
 */
public Long strLen(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.strLen(key);
        }
    });
}

From source file:com.zxy.commons.cache.RedisUtils.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.// w  w w . j a va2 s . c  o  m
 * 
 * @param command Command to execute
 * @param args Possible command arguments (may be null)
 * @return execution result.
 */
public static 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.RedisHelper.java

/**
 * Expire key for seconds//from   w w w .  j  av  a 2  s .co  m
 * <p>
 * See http://redis.io/commands/strlen
 * 
 * @param key must not be {@literal null}.
 * @param seconds seconds time
 * @return Long
 */
public Boolean expire(byte[] key, int seconds) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.expire(key, seconds);
        }
    });
}

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

/**
 * Determine if given {@code key} exists.
 * <p>/*from   ww w . ja  v a2s.c  om*/
 * See http://redis.io/commands/exists
 * 
 * @param key key
 * @return Boolean
 */
public static Boolean exists(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.exists(key);
        }
    });
}