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

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

Introduction

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

Prototype

@Nullable
Long strLen(byte[] key);

Source Link

Document

Get the length of the value stored at key .

Usage

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

public Long size(K key) {
    final byte[] rawKey = rawKey(key);

    return execute(new RedisCallback<Long>() {

        public Long doInRedis(RedisConnection connection) {
            connection.select(dbIndex);/*from  w  ww  .ja  va 2s .c o  m*/
            return connection.strLen(rawKey);
        }
    }, true);
}

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

/**
 * Get the length of the value stored at {@code key}.
 * <p>/*from www.  j  a v  a2 s  .c o  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

/**
 * Get the length of the value stored at {@code key}.
 * <p>/* w w w.java 2  s .com*/
 * 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);
        }
    });
}