30 lines
477 B
Go
30 lines
477 B
Go
package cache
|
|
|
|
import (
|
|
"alfred/utils"
|
|
"time"
|
|
|
|
"github.com/patrickmn/go-cache"
|
|
)
|
|
|
|
type ConfigClientInterface interface {
|
|
PutWithTtl(key string, value interface{}, time time.Duration)
|
|
PutWithDefaultTtl(key string, value interface{})
|
|
Get(key string) (interface{}, bool)
|
|
Delete(key string)
|
|
}
|
|
|
|
type Client struct {
|
|
cacheClient *cache.Cache
|
|
}
|
|
|
|
func NewCacheConfig() *Client {
|
|
|
|
return &Client{
|
|
cacheClient: cache.New(
|
|
5*time.Minute,
|
|
utils.DefaultCacheTtl,
|
|
),
|
|
}
|
|
}
|