Example usage for org.springframework.data.redis.connection RedisConnection hIncrBy

List of usage examples for org.springframework.data.redis.connection RedisConnection hIncrBy

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection RedisConnection hIncrBy.

Prototype

@Nullable
Long hIncrBy(byte[] key, byte[] field, long delta);

Source Link

Document

Increment value of a hash field by the given delta .

Usage

From source file:com.mauersu.util.redis.DefaultHashOperations.java

public Double increment(K key, HK hashKey, final double delta) {
    final byte[] rawKey = rawKey(key);
    final byte[] rawHashKey = rawHashKey(hashKey);

    return execute(new RedisCallback<Double>() {
        public Double doInRedis(RedisConnection connection) {
            connection.select(dbIndex);//from  www . j a v  a2 s  . c om
            return connection.hIncrBy(rawKey, rawHashKey, delta);
        }
    }, true);
}

From source file:com.mauersu.util.redis.DefaultHashOperations.java

public Long increment(K key, HK hashKey, final long delta) {
    final byte[] rawKey = rawKey(key);
    final byte[] rawHashKey = rawHashKey(hashKey);

    return execute(new RedisCallback<Long>() {

        public Long doInRedis(RedisConnection connection) {
            connection.select(dbIndex);/* w  w w.  jav a  2  s.  c  o m*/
            return connection.hIncrBy(rawKey, rawHashKey, delta);
        }
    }, true);

}

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

/**
 * Increment {@code value} of a hash {@code field} by the given {@code delta}.
 * /*from   w ww.j a va 2  s  .  c  om*/
 * @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.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  om*/
 * @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  .j a v  a2s  .com*/
 * @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.RedisHelper.java

/**
 * Increment {@code value} of a hash {@code field} by the given {@code delta}.
 * /*w w w .  j av a 2s . c om*/
 * @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);
        }
    });
}