gocloud.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.

Index

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.

Source Files

atomiccache.go

Version
v0.7.0
Published
Mar 10, 2017
Platform
windows/amd64
Imports
2 packages
Last checked
46 minutes ago

Tools for package owners.