go: cloud.google.com/go/internal/atomiccache Index | Files

package atomiccache

import "cloud.google.com/go/internal/atomiccache"

Package atomiccache provides a map-based cache that supports very fast reads.


Package Files


type Cache Uses

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 Uses

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.

Package atomiccache imports 2 packages (graph) and is imported by 5 packages. Updated 2018-06-20. Refresh now. Tools for package owners.