Java Code Examples for org.springframework.data.redis.core.ListOperations#size()

The following examples show how to use org.springframework.data.redis.core.ListOperations#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisCache.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 获得缓存的list对象
 *
 * @param key 缓存的键值
 * @return 缓存键值对应的数据
 */
public <T> List<T> getCacheList(String key)
{
    List<T> dataList = new ArrayList<T>();
    ListOperations<String, T> listOperation = redisTemplate.opsForList();
    Long size = listOperation.size(key);

    for (int i = 0; i < size; i++)
    {
        dataList.add(listOperation.index(key, i));
    }
    return dataList;
}
 
Example 2
Source File: RedisCacheUtils.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
public long getListSize(String k) {
    String key =  GlobalsConstants.KEY_LIST_PREFIX + k;
    logger.debug("setList key [{}]", key);
    try {
        ListOperations<String, T> listOps = redisTemplate.opsForList();
        return listOps.size(key);
    } catch (Throwable t) {
        logger.error("getListSize key [{}] exception!", key, t);
        throw new CommonException(t);
    }
}
 
Example 3
Source File: RedisCacheUtils.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
public long getListSize(ListOperations<String, String> listOps, String k) {
    String key =  GlobalsConstants.KEY_LIST_PREFIX + k;
    logger.debug("getListSize key [{}]", key);
    try {
        return listOps.size(key);
    } catch (Throwable t) {
        logger.error("getListSize key [{}] exception!", key, t);
        throw new CommonException(t);
    }
}
 
Example 4
Source File: RedisCacheUtils.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
public long getListSize(String k) {
    String key =  GlobalsConstants.KEY_LIST_PREFIX + k;
    logger.debug("setList key [{}]", key);
    try {
        ListOperations<String, T> listOps = redisTemplate.opsForList();
        return listOps.size(key);
    } catch (Throwable t) {
        logger.error("getListSize key [{}] exception!", key, t);
        throw new CommonException(t);
    }
}
 
Example 5
Source File: RedisCacheUtils.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
public long getListSize(ListOperations<String, String> listOps, String k) {
    String key =  GlobalsConstants.KEY_LIST_PREFIX + k;
    logger.debug("getListSize key [{}]", key);
    try {
        return listOps.size(key);
    } catch (Throwable t) {
        logger.error("getListSize key [{}] exception!", key, t);
        throw new CommonException(t);
    }
}
 
Example 6
Source File: RedisCacheUtils.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
public long getListSize(String k) {
    String key =  GlobalsConstants.KEY_LIST_PREFIX + k;
    logger.debug("setList key [{}]", key);
    try {
        ListOperations<String, T> listOps = redisTemplate.opsForList();
        return listOps.size(key);
    } catch (Throwable t) {
        logger.error("getListSize key [{}] exception!", key, t);
        throw new CommonException(t);
    }
}
 
Example 7
Source File: RedisCacheUtils.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
public long getListSize(ListOperations<String, String> listOps, String k) {
    String key =  GlobalsConstants.KEY_LIST_PREFIX + k;
    logger.debug("getListSize key [{}]", key);
    try {
        return listOps.size(key);
    } catch (Throwable t) {
        logger.error("getListSize key [{}] exception!", key, t);
        throw new CommonException(t);
    }
}
 
Example 8
Source File: RedisCacheService.java    From DimpleBlog with Apache License 2.0 5 votes vote down vote up
/**
 * 获得缓存的list对象
 *
 * @param key 缓存的键值
 * @return 缓存键值对应的数据
 */
public <T> List<T> getCacheList(String key) {
    List<T> dataList = new ArrayList<>();
    ListOperations<String, T> listOperation = redisTemplate.opsForList();
    Long size = listOperation.size(key);

    for (int i = 0; i < size; i++) {
        dataList.add(listOperation.index(key, i));
    }
    return dataList;
}
 
Example 9
Source File: CommonRedisDaoImpl.java    From SpringBootUnity with MIT License 5 votes vote down vote up
/**
 * 获取总条数, 可用于分页
 *
 * @param k key
 * @return long
 */
@Override
public long getListSize(String k) {
    try {
        ListOperations<String, String> listOps = redisTemplate.opsForList();
        return listOps.size(KEY_PREFIX_LIST + k);
    } catch (Throwable t) {
        LOGGER.error("获取list长度失败key[" + KEY_PREFIX_LIST + k + "], Codeor[" + t + "]");
    }
    return 0;
}
 
Example 10
Source File: CommonRedisDaoImpl.java    From SpringBootUnity with MIT License 5 votes vote down vote up
/**
 * 获取总条数, 可用于分页
 *
 * @param listOps listOps
 * @param k       k
 * @return long
 */
@Override
public long getListSize(ListOperations<String, String> listOps, String k) {
    try {
        return listOps.size(KEY_PREFIX_LIST + k);
    } catch (Throwable t) {
        LOGGER.error("获取list长度失败key[" + KEY_PREFIX_LIST + k + "], Codeor[" + t + "]");
    }
    return 0;
}
 
Example 11
Source File: RedisServiceImpl.java    From DouBiNovel with Apache License 2.0 4 votes vote down vote up
@Override
public Long size(String key) {
    ListOperations<String, String> operations = this.template.opsForList();
    return operations.size(key);
}