Documentation ¶
Overview ¶
Package atomiccache provides a map-based cache that supports very fast reads.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a map-based cache that supports fast reads via use of atomics. Writes are slow, requiring a copy of the entire cache. The zero Cache is an empty cache, ready for use.
func (*Cache) Get ¶
func (c *Cache) Get(key interface{}, getter func() interface{}) interface{}
Get returns the value of the cache at key. If there is no value, getter is called to provide one, and the cache is updated. The getter function may be called concurrently. It should be pure, returning the same value for every call.
Click to show internal directories.
Click to hide internal directories.