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

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

Introduction

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

Prototype

@Nullable
Long sCard(byte[] key);

Source Link

Document

Get size of set at key .

Usage

From source file:com.mauersu.util.redis.DefaultSetOperations.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   ww w  .  j a va  2  s . c  o  m*/
            return connection.sCard(rawKey);
        }
    }, true);
}

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

/**
 * Get size of set at {@code key}.// w w w.  j  a v  a 2  s.c  o m
 * <p>
 * See http://redis.io/commands/scard
 * 
 * @param key key
 * @return Long
 */
public static Long sCard(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sCard(key);
        }
    });
}

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

/**
 * Get size of set at {@code key}.//from   w  w w.jav a 2s.  com
 * <p>
 * See http://redis.io/commands/scard
 * 
 * @param key key
 * @return Long
 */
public Long sCard(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sCard(key);
        }
    });
}