Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNegativeReferenceCount = errors.New("internal error: negative reference count")
Functions ¶
func NewCacheWithDisposal ¶ added in v0.21.3
func NewCacheWithDisposal(p ParamsWithDisposal) *shardedCacheWithDisposal
Types ¶
type CacheWithDisposal ¶ added in v0.21.3
type CacheWithDisposal interface {
Name() string
GetOrSet(k interface{}, setFn SetFn) (v interface{}, disposer Derefer, err error)
}
CacheWithDisposal is a cache that calls a disposal callback when an entry has been evicted and is no longer in use. Because of the structure of Go, it uses release callbacks and is not a Cache.
type ChanOnlyOne ¶ added in v0.21.2
type ChanOnlyOne struct {
// contains filtered or unexported fields
}
func NewChanOnlyOne ¶ added in v0.21.2
func NewChanOnlyOne() *ChanOnlyOne
func (*ChanOnlyOne) Compute ¶ added in v0.21.2
func (c *ChanOnlyOne) Compute(k interface{}, fn func() (interface{}, error)) (interface{}, error)
type Derefer ¶ added in v0.21.3
type Derefer func() error
Derefer is the type of a function that returns an object to the cache, possibly causing its eviction.
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)
type JitterFn ¶
func NewJitterFn ¶
type OnlyOne ¶ added in v0.21.2
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 ParamsWithDisposal ¶ added in v0.21.3
type SingleThreadedCacheWithDisposal ¶ added in v0.21.3
type SingleThreadedCacheWithDisposal struct {
// contains filtered or unexported fields
}
SingleThreadedCacheWithDisposal is a CacheWithDisposal that uses a single critical section to prevent concurrent access to the cache and to reference counts on values.
func NewSingleThreadedCacheWithDisposal ¶ added in v0.21.3
func NewSingleThreadedCacheWithDisposal(p ParamsWithDisposal) *SingleThreadedCacheWithDisposal
func (*SingleThreadedCacheWithDisposal) GetOrSet ¶ added in v0.21.3
func (c *SingleThreadedCacheWithDisposal) GetOrSet(k interface{}, setFn SetFn) (interface{}, Derefer, error)
func (*SingleThreadedCacheWithDisposal) Name ¶ added in v0.21.3
func (c *SingleThreadedCacheWithDisposal) Name() string
Click to show internal directories.
Click to hide internal directories.