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

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

Introduction

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

Prototype

@Nullable
Long incr(byte[] key);

Source Link

Document

Increment an integer value stored as string value of key by 1.

Usage

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

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

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

/**
 * Increment value of {@code key} by 1.//from  www.ja v  a2s.c  om
 * <p>
 * See http://redis.io/commands/incr
 * 
 * @param key must not be {@literal null}.
 * @return Long
 */
public Long incr(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.incr(key);
        }
    });
}