synccache

package
v0.8.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constructor

type Constructor func(ctx context.Context, key interface{}) (value interface{}, err error)

Constructor is a func that is used to construct a cache value, given a key.

type SyncCache

type SyncCache struct {
	// contains filtered or unexported fields
}

SyncCache is an object which can be used to create singletons stored in a key-value store.

func New

func New() *SyncCache

New creates an empty SyncCache.

func (*SyncCache) Add

func (sc *SyncCache) Add(ctx context.Context, key interface{}, value interface{}, valueErr error) error

Add adds a readily constructed value for a given key.

func (*SyncCache) Do

func (sc *SyncCache) Do(ctx context.Context, key interface{}, c Constructor) (interface{}, error)

Do executes the constructor, if a value for key hasn't already been constructed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL