feature/ip优化
This commit is contained in:
@@ -75,17 +75,12 @@ func NewRedisCache(client *redis.Client) *RedisCache {
|
||||
return &RedisCache{client: client}
|
||||
}
|
||||
|
||||
func (r *RedisCache) Set(ctx context.Context, ip string, info ApiResult, ttl time.Duration) error {
|
||||
func (r *RedisCache) Set(ctx context.Context, ip string, info string, ttl time.Duration) error {
|
||||
if ip == "" {
|
||||
return errors.New("ip不能为空")
|
||||
}
|
||||
|
||||
data, err := json.Marshal(info)
|
||||
if err != nil {
|
||||
return fmt.Errorf("无法封送IP信息: %w", err)
|
||||
}
|
||||
|
||||
return r.client.Set(ctx, ip, data, ttl).Err()
|
||||
return r.client.Set(ctx, ip, info, ttl).Err()
|
||||
}
|
||||
|
||||
// Get 从Redis获取IP信息
|
||||
|
Reference in New Issue
Block a user