cache

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncFetcher

type AsyncFetcher[K comparable, V any] interface {
	FetchAll(ctx context.Context) (map[K]V, error)
}

type KeylessFetcher

type KeylessFetcher[V any] interface {
	Fetch(ctx context.Context) (V, error)
}

type KeylessRecordCache

type KeylessRecordCache[V any] struct {
	*RecordCache[int, V]
}

KeylessRecordCache to allow rotation of a cache with only one value a prime use case being a token cache for a service like salesforce

func NewKeylessRecordCacheAsync

func NewKeylessRecordCacheAsync[V any](driver driver.Cache[int, RecordCacheItem[V]], f KeylessFetcher[V], ttl time.Duration) *KeylessRecordCache[V]

func NewKeylessRecordCacheAsyncWithLogger

func NewKeylessRecordCacheAsyncWithLogger[V any](driver driver.Cache[int, RecordCacheItem[V]], f KeylessFetcher[V], ttl time.Duration, log *zap.Logger) *KeylessRecordCache[V]

func NewKeylessRecordCacheOnDemand

func NewKeylessRecordCacheOnDemand[V any](driver driver.Cache[int, RecordCacheItem[V]], f KeylessFetcher[V], ttl time.Duration) *KeylessRecordCache[V]

func (*KeylessRecordCache[V]) Get

func (k *KeylessRecordCache[V]) Get(ctx context.Context) (V, error)

type OnDemandFetcher

type OnDemandFetcher[K comparable, V any] interface {
	FetchByKey(ctx context.Context, k K) (V, error)
}

type RecordCache

type RecordCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

RecordCache for a detailed explanation of the below, RecordCacheItem, KeylessRecordCache and driver.Cache please see https://ellogroup.atlassian.net/wiki/spaces/EP/pages/12648450/Cache+Package

func NewRecordCache

func NewRecordCache[K comparable, V any](cache driver.Cache[K, RecordCacheItem[V]]) *RecordCache[K, V]

func (*RecordCache[K, V]) AddLogger

func (r *RecordCache[K, V]) AddLogger(l *zap.Logger) *RecordCache[K, V]

func (*RecordCache[K, V]) Get

func (r *RecordCache[K, V]) Get(ctx context.Context, k K) (V, error)

func (*RecordCache[K, V]) SetAsyncFetcher

func (r *RecordCache[K, V]) SetAsyncFetcher(f AsyncFetcher[K, V], ttl time.Duration) *RecordCache[K, V]

func (*RecordCache[K, V]) SetOnDemandFetcher

func (r *RecordCache[K, V]) SetOnDemandFetcher(f OnDemandFetcher[K, V], ttl time.Duration) *RecordCache[K, V]

type RecordCacheItem

type RecordCacheItem[V any] struct {
	V V
	T time.Time
}

func (*RecordCacheItem[V]) IsStale

func (rci *RecordCacheItem[V]) IsStale(ttl time.Duration) bool

Jump to

Keyboard shortcuts

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