backedcache

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

backedcache wraps github.com/barrett370/go-cache#Cache[V] with a backend, requests for keys not in the underlying cache will fetch (via a singleflight group to prevent stampeding) via a user-defined GetterFn[K,V]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(ctx context.Context, key K) (V, error)

type CacheKey

type CacheKey interface {
	comparable
	String() string
	Expiration() time.Duration
}

type Cacher

type Cacher[K CacheKey, V any] interface {
	Getter[K, V]
}

type Getter

type Getter[K CacheKey, V any] interface {
	Get(context.Context, K) (V, error)
}

type GetterFn

type GetterFn[K CacheKey, V any] func(ctx context.Context, key K) (V, error)

Jump to

Keyboard shortcuts

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