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

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

Introduction

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

Prototype

@Nullable
Long decr(byte[] key);

Source Link

Document

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

Usage

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

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

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

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