2019-06-13 03:55:38 -05:00
|
|
|
package localcache
|
2018-10-26 03:40:33 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
gocache "github.com/patrickmn/go-cache"
|
|
|
|
)
|
|
|
|
|
2019-06-13 03:55:38 -05:00
|
|
|
// CacheService cache any object in memory on the local instance.
|
2018-10-26 03:40:33 -05:00
|
|
|
type CacheService struct {
|
|
|
|
*gocache.Cache
|
|
|
|
}
|
|
|
|
|
2021-08-25 08:11:22 -05:00
|
|
|
func ProvideService() *CacheService {
|
|
|
|
return New(5*time.Minute, 10*time.Minute)
|
|
|
|
}
|
|
|
|
|
2019-06-13 03:55:38 -05:00
|
|
|
// New returns a new CacheService
|
2018-10-26 03:40:33 -05:00
|
|
|
func New(defaultExpiration, cleanupInterval time.Duration) *CacheService {
|
|
|
|
return &CacheService{
|
|
|
|
Cache: gocache.New(defaultExpiration, cleanupInterval),
|
|
|
|
}
|
|
|
|
}
|