Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { GetOrSet(k interface{}, setFn SetFn) (v interface{}, err error) GetOrSetWithExpiry(k interface{}, setFn SetFnWithExpiry) (v interface{}, err error) }
var NoCache Cache = &noCache{}
type ChanOnlyOne ¶
type ChanOnlyOne struct {
// contains filtered or unexported fields
}
func NewChanOnlyOne ¶
func NewChanOnlyOne() *ChanOnlyOne
func (*ChanOnlyOne) Compute ¶
func (c *ChanOnlyOne) Compute(k interface{}, fn func() (interface{}, error)) (interface{}, error)
type GetSetCache ¶
type GetSetCache struct {
// contains filtered or unexported fields
}
func (*GetSetCache) GetOrSet ¶
func (c *GetSetCache) GetOrSet(k interface{}, setFn SetFn) (v interface{}, err error)
func (*GetSetCache) GetOrSetWithExpiry ¶ added in v1.8.0
func (c *GetSetCache) GetOrSetWithExpiry(k interface{}, setFn SetFnWithExpiry) (v interface{}, err error)
type JitterFn ¶
func NewJitterFn ¶
type OnlyOne ¶
type OnlyOne interface { // Compute returns the value of calling fn(), but only calls fn once concurrently for // each k. Compute(k interface{}, fn func() (interface{}, error)) (interface{}, error) }
OnlyOne ensures only one concurrent evaluation of a keyed expression.
type SetFnWithExpiry ¶ added in v1.8.0
SetWithExpiry is a function called to set a value in the cache. It returns the desired value and when to expire it from the cache. The cache default expiration value is used if it returns a zero expiration.
Click to show internal directories.
Click to hide internal directories.