Documentation ¶
Overview ¶
Package drpccache implements per stream cache for drpc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a per stream cache.
func FromContext ¶
FromContext returns a cache from a context.
Example usage:
cache := drpccache.FromContext(stream.Context()) if cache != nil { value := cache.LoadOrCreate("initialized", func() (interface{}) { return 42 }) }
func (*Cache) Load ¶
func (cache *Cache) Load(key interface{}) interface{}
Load returns the value with the given key.
func (*Cache) LoadOrCreate ¶
func (cache *Cache) LoadOrCreate(key interface{}, fn func() interface{}) interface{}
LoadOrCreate returns the value with the given key.
Click to show internal directories.
Click to hide internal directories.