bigwolftime / gitmentCommentsPlugin

0 stars 0 forks source link

Redis pipeline #36

Open bigwolftime opened 3 years ago

bigwolftime commented 3 years ago

https://bigwolftime.github.io/redis-pipeline/

文中使用 Jedis 进行数据交互, 版本为 2.6.1

一. 使用场景

我们在使用 Redis 的过程中, 不免要进行批量的数据操作, 例如: 根据一个 uidList 查询出每个用户的信息, 假设用户信息的缓存使用 Key-Value 结构存储, 在不使用 pipeline 的情况下, 我们的代码可能是这样的(以 Jedis 组件为例):

public List getUserInfoByUids(List uidList) { List userList = new ArrayList<>();

for (long uid : uidList) {
    userList.add(jedis.get(