Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis 设置过期时间问题 #46

Closed
pikefeier opened this issue Aug 23, 2022 · 1 comment
Closed

redis 设置过期时间问题 #46

pikefeier opened this issue Aug 23, 2022 · 1 comment

Comments

@pikefeier
Copy link

/**
* 一次性添加数组到 过期时间的 缓存,不用多次连接,节省开销
*
* @param keys redis主键数组
* @param values 值数组
* @param time 过期时间(单位秒)
*/
public void setExpire(final String[] keys, final Object[] values, final long time) {
for (int i = 0; i < keys.length; i++) {
redisTemplate.opsForValue().set(keys[i], values[i], time, TimeUnit.SECONDS);
}
}
上述代码:怎么做到不用多次连接,节省开销?

@zlt2000
Copy link
Owner

zlt2000 commented Mar 12, 2023

可以用pipeline

@zlt2000 zlt2000 closed this as completed May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants