Remove cache expiration for link service

This commit is contained in:
Andrey Chervyakov 2021-03-16 13:26:25 +06:00
parent 398d32f967
commit e426559cec

View file

@ -3,7 +3,6 @@ package link
import (
apperrors "cgnolink/errors"
"github.com/patrickmn/go-cache"
"time"
)
type Service interface {
@ -22,7 +21,7 @@ type PgService struct {
func NewPgService(rep PgRepository) PgService {
return PgService{
rep: rep,
cache: cache.New(1*time.Hour, 90*time.Minute),
cache: cache.New(cache.NoExpiration, 0),
}
}
@ -59,7 +58,7 @@ func (s *PgService) GetById(id string) (*Link, error) {
return nil, apperrors.NotFoundError{Message: "Link with given ID was not found."}
}
s.cache.Set(id, link, 0)
s.cache.Set(id, link, cache.DefaultExpiration)
return link, nil
}