store

package
v4.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 4 Imported by: 167

Documentation

Index

Constants

View Source
const NOT_FOUND_ERR string = "value not found in store"

Variables

This section is empty.

Functions

func NotFoundWithCause

func NotFoundWithCause(e error) error

Types

type InvalidateOption

type InvalidateOption func(o *InvalidateOptions)

InvalidateOption represents a cache invalidation function.

func WithInvalidateTags

func WithInvalidateTags(tags []string) InvalidateOption

WithInvalidateTags allows setting the invalidate tags.

type InvalidateOptions

type InvalidateOptions struct {
	Tags []string
}

func ApplyInvalidateOptions

func ApplyInvalidateOptions(opts ...InvalidateOption) *InvalidateOptions

func ApplyInvalidateOptionsWithDefault

func ApplyInvalidateOptionsWithDefault(defaultOptions *InvalidateOptions, opts ...InvalidateOption) *InvalidateOptions

type InvalidateOptionsMatcher

type InvalidateOptionsMatcher struct {
	Tags []string
}

func (InvalidateOptionsMatcher) Matches

func (m InvalidateOptionsMatcher) Matches(x interface{}) bool

func (InvalidateOptionsMatcher) String

func (m InvalidateOptionsMatcher) String() string

type NotFound

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

func (NotFound) Cause

func (e NotFound) Cause() error

func (NotFound) Error

func (e NotFound) Error() string

func (NotFound) Is

func (e NotFound) Is(err error) bool

func (NotFound) Unwrap

func (e NotFound) Unwrap() error

type Option

type Option func(o *Options)

Option represents a store option function.

func WithClientSideCaching

func WithClientSideCaching(clientSideCacheExpiration time.Duration) Option

WithClientSideCaching allows setting the client side caching, enabled by default Currently to be used by Rueidis(redis) library only.

func WithCost

func WithCost(cost int64) Option

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

func WithExpiration(expiration time.Duration) Option

WithExpiration allows to specify an expiration time when setting a value.

func WithSynchronousSet added in v4.1.6

func WithSynchronousSet() Option

WithSynchronousSet allows setting the behavior when setting a value, whether to wait until all buffered writes have been applied or not. Currently to be used by Ristretto library only.

func WithTags

func WithTags(tags []string) Option

WithTags allows to specify associated tags to the current value.

func WithTagsTTL added in v4.2.1

func WithTagsTTL(ttl time.Duration) Option

WithTagsTTL allows to specify a time-to-live parameter for tags

type Options

type Options struct {
	SynchronousSet            bool
	Cost                      int64
	Expiration                time.Duration
	Tags                      []string
	TagsTTL                   time.Duration
	ClientSideCacheExpiration time.Duration
}

func ApplyOptions

func ApplyOptions(opts ...Option) *Options

func ApplyOptionsWithDefault

func ApplyOptionsWithDefault(defaultOptions *Options, opts ...Option) *Options

func (*Options) IsEmpty

func (o *Options) IsEmpty() bool

type OptionsMatcher

type OptionsMatcher struct {
	Cost       int64
	Expiration time.Duration
	Tags       []string
}

func (OptionsMatcher) Matches

func (m OptionsMatcher) Matches(x interface{}) bool

func (OptionsMatcher) String

func (m OptionsMatcher) String() string

type StoreInterface

type StoreInterface 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
	Invalidate(ctx context.Context, options ...InvalidateOption) error
	Clear(ctx context.Context) error
	GetType() string
}

StoreInterface is the interface for all available stores

Jump to

Keyboard shortcuts

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