如何在 Jedis Client 的 RedisTemplate 中的一次调用中获取多个列表值 [英] How to get multiple list values in one single call in RedisTemplate of Jedis Client

查看:62
本文介绍了如何在 Jedis Client 的 RedisTemplate 中的一次调用中获取多个列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 RedisTemplate 以列表形式获取和存储数据.当我存储数据时 - 我将其存储为

I am using RedisTemplate to get and store data as a list. When I am storing data - I store it as

redisTemplate.opsForList().rightPush("key1", "value11");
redisTemplate.opsForList().rightPush("key1", "value12");
redisTemplate.opsForList().rightPush("key2", "value21");
redisTemplate.opsForList().rightPush("key2", "value22");

现在我想在一次调用中获取两个键的列表值我可以单独获得

Now I want to get the list values for both the keys in one single call I can get individually by

redisTemplate.opsForList().range("key1", 0, -1);
redisTemplate.opsForList().range("key2", 0, -1);

但是有没有办法在列表中使用 multi get .如果值是字符串类型,我可以使用多站点,但我没有看到任何带有列表的 api.

But is there a way to use multi get with list. If the values are of type string, I am able to use multisite, but I dont see any api with list.

推荐答案

您不需要专用的 API,只需 流水线.

You don't need a dedicated API, but simply pipelining.

在以下位置查看一些示例:https://github.com/xetorthio/jedis/blob/master/src/test/java/redis/clients/jedis/tests/PipeliningTest.java

See some examples at: https://github.com/xetorthio/jedis/blob/master/src/test/java/redis/clients/jedis/tests/PipeliningTest.java

这篇关于如何在 Jedis Client 的 RedisTemplate 中的一次调用中获取多个列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆