Documentation
¶
Index ¶
Constants ¶
const NOT_FOUND_ERR string = "value not found in store"
Variables ¶
var ErrNotSupported = errors.New("operation not supported by this store")
ErrNotSupported is returned by operations that the underlying store is not able to perform.
Functions ¶
func NotFoundWithCause ¶
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 Option ¶
type Option func(o *Options)
Option represents a store option function.
func WithClientSideCaching ¶
WithClientSideCaching allows setting the client side caching, enabled by default Currently to be used by Rueidis(redis) library only.
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.
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 WithTagsTTL ¶ added in v4.2.1
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 ApplyOptionsWithDefault ¶
type OptionsMatcher ¶
func (OptionsMatcher) Matches ¶
func (m OptionsMatcher) Matches(x interface{}) bool
func (OptionsMatcher) String ¶
func (m OptionsMatcher) String() string
type SetIfNotExistsStore ¶ added in v4.3.0
type SetIfNotExistsStore interface {
StoreInterface
// SetIfNotExists sets the value for the given key only when it does not
// already exist, and reports whether it has been written.
SetIfNotExists(ctx context.Context, key any, value any, options ...Option) (bool, error)
}
SetIfNotExistsStore is implemented by stores able to atomically write a value only when the key does not exist yet.
It is an optional interface: stores whose client has no such primitive do not implement it, and cache.Cache returns ErrNotSupported for them.
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