From 0bbbfa3c1e15d00c6941086582e29b67304cfc8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E7=BF=A0=E4=B8=BD?= <15812412904> Date: Tue, 17 Jun 2025 17:03:31 +0800 Subject: [PATCH] =?UTF-8?q?feature/ip=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ip_tool/hua_chen_client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ip_tool/hua_chen_client.go b/ip_tool/hua_chen_client.go index 931090c..46aaf5a 100644 --- a/ip_tool/hua_chen_client.go +++ b/ip_tool/hua_chen_client.go @@ -90,7 +90,7 @@ func (h *HuaChenIpClient) GetIpInfo(ip string) (res *ApiResult, err error) { return &apiResult, nil } -func (h *HuaChenIpClient) GetIpInfoFormCache(ctx context.Context, ip string) (res *ApiResult, err error) { +func (h *HuaChenIpClient) GetIpInfoFormCache(ctx context.Context, ip string, ttl time.Duration) (res *ApiResult, err error) { getCache, err := h.cache.Get(ctx, h.ipKey(ip)) if err != nil { return nil, errors.Wrapf(err, "获取缓存失败,ip:%s", ip) @@ -108,7 +108,7 @@ func (h *HuaChenIpClient) GetIpInfoFormCache(ctx context.Context, ip string) (re return nil, errors.Wrapf(err, "无法将IP信息转换为JSON,ip:%s", ip) } - err = h.cache.Set(ctx, h.ipKey(ip), string(infoJson), 24*time.Hour) + err = h.cache.Set(ctx, h.ipKey(ip), string(infoJson), ttl) if err != nil { return nil, errors.Wrapf(err, "缓存ip:%s信息失败,", ip) }