type Cache struct {
MaxLifetime time.Duration
// contains filtered or unexported fields
}
func Clear(cacheName string) ([]*Cache, error)
clear the entire cache with this name and return cache objects (which cleared)
func New(name string, lifetime time.Duration, maxSizeInMB int) *Cache
create a new cache. "name" must be a prometheus metric compatible name and unique throughout good practice: prefix it with servicepackagename. for example:
servicename: "lbproxy.LBProxyService"
-> cachename: "lbproxy_tokencache"
func (c *Cache) Clear()
clear this cache (that is: remove all entries in it)
func (c *Cache) Evict(key string)
evict (aka remove) a specific key from this cache
func (c *Cache) Get(key string) interface{}
get something from the cache (specified by key)
func (c *Cache) Keys() []string
get all the keys from the cache
func (c *Cache) Name() string
return the name of this cache
func (c *Cache) Put(key string, value interface{})
put something into this cache
func (c *Cache) PutWithExpiry(key string, value interface{}, expiry *time.Time)
put something into this cache, with a specific expiry time
type CachingResolver interface {
Retrieve(key string, fr func(string) (interface{}, error)) (interface{}, error)
RetrieveContext(ctx context.Context, key string, fr func(context.Context, string) (interface{}, error)) (interface{}, error)
SetRefreshAfter(time.Duration)
SetAsyncRetriever(fr func(string) (interface{}, error))
Evict(key string)
Clear()
Keys() []string
}
func NewResolvingCache(name string, lifetime time.Duration, maxLimitEntries int) CachingResolver