【发布时间】:2020-05-05 00:17:38
【问题描述】:
我使用 golang 作为我的后端。我在 redis 中存储了一些令牌值。我正在设置值 HSET 并在 HGETALL 中获取值。我想知道是否有任何函数可以设置键的到期时间我存储在 redis 数据库中。我希望在 1 小时后删除令牌及其数据。我正在为 redis 使用 Redigo 包。谢谢。感谢您的帮助。
I use this to set the struct with has token as key
redisCon.Do("HMSET", redis.Args{}.Add(hashToken).AddFlat(&dataStruct)...)
【问题讨论】:
-
你应该告诉别人你使用什么redis库。您也可以在“godoc.com”中搜索如何使用它
-
我在客户端使用 redigo 库与 redigo 服务器连接..我像这样使用 c.Do("HMSET", ciphertext, 3200, datastruct)。这里 cipertext 是关键, 3200 是 ttl,datastruct 是包含令牌详细信息的结构。但是检查 ttl 的那个键它显示 -1...感谢任何帮助。谢谢