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.RedisUtils.java

/**
 * Set multiple hash fields to multiple values using data provided in {@code hashes}
 * /*from   w  ww  .ja v a2  s .  c  o m*/
 * @see http://redis.io/commands/hmset
 * @param key key
 * @param hashes hashes
 */
public static void hMSet(byte[] key, Map<byte[], byte[]> hashes) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.hMSet(key, hashes);
            return null;
        }
    });
}

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

/**
 * Set multiple hash fields to multiple values using data provided in {@code hashes}
 * /*from w w  w . j ava2  s .  c  om*/
 * @see http://redis.io/commands/hmset
 * @param key key
 * @param hashes hashes
 */
public void hMSet(byte[] key, Map<byte[], byte[]> hashes) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.hMSet(key, hashes);
            return null;
        }
    });
}

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

/**
 * Increment {@code value} of a hash {@code field} by the given {@code delta}.
 * /*from   w w  w. j  av  a  2  s  .  c o m*/
 * @see http://redis.io/commands/hincrby
 * @param key key
 * @param field field
 * @param delta delta
 * @return Long
 */
public static Long hIncrBy(byte[] key, byte[] field, long delta) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hIncrBy(key, field, delta);
        }
    });
}

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

/**
 * Increment {@code value} of a hash {@code field} by the given {@code delta}.
 * /*from w  w w  . j  av a2 s.c  om*/
 * @see http://redis.io/commands/hincrby
 * @param key key
 * @param field field
 * @param delta delta
 * @return Long
 */
public Long hIncrBy(byte[] key, byte[] field, long delta) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hIncrBy(key, field, delta);
        }
    });
}

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

/**
 * Increment {@code value} of a hash {@code field} by the given {@code delta}.
 * //from w  w w .  j  a  v  a2  s.c o  m
 * @see http://redis.io/commands/hincrbyfloat
 * @param key key
 * @param field field
 * @param delta delta
 * @return Double
 */
public static Double hIncrBy(byte[] key, byte[] field, double delta) {
    return redisTemplate.execute(new RedisCallback<Double>() {
        @Override
        public Double doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hIncrBy(key, field, delta);
        }
    });
}

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

/**
 * Increment {@code value} of a hash {@code field} by the given {@code delta}.
 * /*from   w w  w  .ja  va  2s  .  co m*/
 * @see http://redis.io/commands/hincrbyfloat
 * @param key key
 * @param field field
 * @param delta delta
 * @return Double
 */
public Double hIncrBy(byte[] key, byte[] field, double delta) {
    return redisTemplate.execute(new RedisCallback<Double>() {
        @Override
        public Double doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hIncrBy(key, field, delta);
        }
    });
}

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

/**
 * Determine if given hash {@code field} exists.
 * /*from  w  w  w.j av  a 2 s .  co  m*/
 * @see http://redis.io/commands/hexits
 * @param key key
 * @param field field
 * @return Boolean
 */
public static Boolean hExists(byte[] key, byte[] field) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hExists(key, field);
        }
    });
}

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

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

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

/**
 * Delete given hash {@code fields}.//from  w  w w.j  a  va  2s.c om
 * 
 * @see http://redis.io/commands/hdel
 * @param key key
 * @param fields fields
 * @return Long
 */
public static Long hDel(byte[] key, byte[]... fields) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hDel(key, fields);
        }
    });
}

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

/**
 * Delete given hash {@code fields}.//from w  ww.  j a  v  a2  s  . c o  m
 * 
 * @see http://redis.io/commands/hdel
 * @param key key
 * @param fields fields
 * @return Long
 */
public Long hDel(byte[] key, byte[]... fields) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.hDel(key, fields);
        }
    });
}