gcache

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 5 Imported by: 0

README

gcache

Concurrency-safe Go caching library with generics support, different data storages and stats monitoring.

GoVersion Build GoReportCard CoverageStatus GoDoc License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = store.ErrNotFound

ErrNotFound indicates that key not found in the cache.

Functions

This section is empty.

Types

type Cache added in v0.0.4

type Cache[KeyType comparable, ValueType any] interface {
	Get(KeyType) (ValueType, error)
	Set(KeyType, ValueType) error
	Delete(KeyType) error
	Clear() error

	GetWithContext(context.Context, KeyType) (ValueType, error)
	SetWithContext(context.Context, KeyType, ValueType) error
	DeleteWithContext(context.Context, KeyType) error
	ClearWithContext(context.Context) error

	SetHasher(hasher.Hasher)
	SetMarshaler(marshaler.Marshaler)
}

Cache represents the interface for all caches

func New added in v0.0.4

func New[K comparable, V any](s store.Store) Cache[K, V]

New creates a new instance of cache object.

func NewMapCache added in v0.0.6

func NewMapCache[K comparable, V any](size int) Cache[K, V]

NewMapCache creates a new instance of cache object with the MapStore as a data store. MapStore is like a Go map but is safe for concurrent use by multiple goroutines.

Directories

Path Synopsis
internal
pkg

Jump to

Keyboard shortcuts

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