redis get list
时间: 2023-10-06 08:08:20 浏览: 169
要从Redis中获取一个列表,可以使用LRANGE命令。例如,使用jedis.lrange(key, 0, -1)可以获取名为key的列表的所有元素。这个方法不会影响Redis列表中的数据。可以通过以下代码实现:
List<String> list = new ArrayList<>();
String st = jedis.lpop(key);
while (st != null) {
list.add(st);
st = jedis.lpop(key);
}
这样,list就包含了从Redis列表中获取到的所有元素。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [redis 获取 list 中的所有元素](https://blog.csdn.net/m0_55613022/article/details/124015007)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [redis常见操作命令-list](https://blog.csdn.net/xyblog/article/details/50535226)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文