gpt4 book ai didi

node.js - set ioredis 设置过期时间

转载 作者:可可西里 更新时间:2023-11-01 11:13:05 26 4
gpt4 key购买 nike

我正在尝试为 ioredis nodejs 中的一组值设置过期时间。我可以使用此命令将一组添加到 reids

redis.sadd('set', 1, 3, 5, 7);

但是我需要为这个集合设置一个过期时间。我该怎么做?

最佳答案

您可以使用 expire

redis.expire('set', 10);

expire 的一般语法是 EXPIRE KEY_NAME TIME_IN_SECONDS

multiple方法来做到这一点,只有当你想尝试其他方法时。

关于node.js - set ioredis 设置过期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42111608/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com