feature/ip优化

This commit is contained in:
吕翠丽
2025-06-17 16:57:42 +08:00
parent 6d3891390f
commit 169996cc8a
3 changed files with 10 additions and 9 deletions

View File

@@ -102,7 +102,13 @@ func (h *HuaChenIpClient) GetIpInfoFormCache(ctx context.Context, ip string) (re
if err != nil {
return nil, errors.Wrapf(err, "获取ip:%s信息失败", ip)
}
err = h.cache.Set(ctx, h.ipKey(ip), *info, 24*time.Hour)
infoJson, err := json.Marshal(info)
if err != nil {
return nil, errors.Wrapf(err, "无法将IP信息转换为JSONip:%s", ip)
}
err = h.cache.Set(ctx, h.ipKey(ip), string(infoJson), 24*time.Hour)
if err != nil {
return nil, errors.Wrapf(err, "缓存ip:%s信息失败", ip)
}