Documentation ¶
Index ¶
- Constants
- Variables
- type Key
- func (k *Key[T]) Delete(ctx context.Context) error
- func (k *Key[T]) Get(ctx context.Context) (*T, error)
- func (k *Key[T]) GetWithFallBack(ctx context.Context, fallBackFunc fallBackFunc[T], options ...Option) (*T, error)
- func (k *Key[T]) GetWithTTL(ctx context.Context) (*T, time.Duration, error)
- func (k *Key[T]) Set(ctx context.Context, value *T, options ...Option) error
- type Map
- func (m *Map[K, V]) Delete(ctx context.Context, key K) error
- func (m *Map[K, V]) Get(ctx context.Context, key K) (*V, error)
- func (m *Map[K, V]) GetWithFallBack(ctx context.Context, key K, fallBackFunc mapFallBackFunc[K, V], ...) (*V, error)
- func (m *Map[K, V]) GetWithTTL(ctx context.Context, key K) (*V, time.Duration, error)
- func (m *Map[K, V]) Set(ctx context.Context, key K, value *V, options ...Option) error
- type NotFoundError
- type Option
- type Options
- type Store
Constants ¶
View Source
const NotFoundErr string = "value not found in store"
Variables ¶
View Source
var ProviderSet = wire.NewSet(NewStore)
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key[T any] struct { // contains filtered or unexported fields }
func (*Key[T]) GetWithFallBack ¶
func (*Key[T]) GetWithTTL ¶
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
func (NotFoundError) Cause ¶
func (e NotFoundError) Cause() error
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
func (NotFoundError) Is ¶
func (e NotFoundError) Is(err error) bool
func (NotFoundError) Unwrap ¶
func (e NotFoundError) Unwrap() error
type Option ¶
type Option func(o *Options)
Option represents a store option function.
func WithCost ¶
WithCost allows setting the memory capacity used by the item when setting a value. Actually it seems to be used by Ristretto library only.
func WithExpiration ¶
WithExpiration allows to specify an expiration time when setting a value.
type Store ¶
type Store interface { Get(ctx context.Context, key any) (any, error) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error) Set(ctx context.Context, key any, value any, options ...Option) error Delete(ctx context.Context, key any) error Clear(ctx context.Context) error }
Store is the interface for all available stores Inspired by https://github.com/eko/gocache
Click to show internal directories.
Click to hide internal directories.