From a7d87475af8768ad23f81f84a4894c35c9a9cc29 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Tue, 17 Jun 2025 02:37:19 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(redis):=20only=20set=20expir?= =?UTF-8?q?ation=20if=20greater=20than=200=20in=20RedisHSetObj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/redis.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/redis.go b/common/redis.go index ba35331a..1efc217f 100644 --- a/common/redis.go +++ b/common/redis.go @@ -141,7 +141,11 @@ func RedisHSetObj(key string, obj interface{}, expiration time.Duration) error { txn := RDB.TxPipeline() txn.HSet(ctx, key, data) - txn.Expire(ctx, key, expiration) + + // 只有在 expiration 大于 0 时才设置过期时间 + if expiration > 0 { + txn.Expire(ctx, key, expiration) + } _, err := txn.Exec(ctx) if err != nil {