Documentation
¶
Overview ¶
Package memcached provides a Memcached-backed cache store.
Index ¶
- Variables
- type Locker
- type LockerOption
- type Option
- type Store
- func (s *Store[K, V]) Get(ctx context.Context, namespace string, key K) (cache.Entry[V], bool, error)
- func (s *Store[K, V]) Invalidate(ctx context.Context, namespace string, key K) error
- func (s *Store[K, V]) InvalidateAll(ctx context.Context, namespace string) error
- func (s *Store[K, V]) Set(ctx context.Context, namespace string, key K, entry cache.Entry[V]) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilClient = errors.New("cache memcached: client must not be nil") ErrNilCodec = errors.New("cache memcached: codec must not be nil") )
Functions ¶
This section is empty.
Types ¶
type Locker ¶
type Locker[K comparable] struct { // contains filtered or unexported fields }
Locker provides renewable Memcached leases using add and CAS.
func NewLocker ¶
func NewLocker[K comparable](client *memcache.Client, options ...LockerOption[K]) (*Locker[K], error)
NewLocker constructs a Memcached locker using a caller-owned client.
type LockerOption ¶
type LockerOption[K comparable] func(*lockerConfig[K]) error
LockerOption configures Memcached lock key serialization.
func WithLockerKeyCodec ¶
func WithLockerKeyCodec[K comparable](codec cache.Codec[K]) LockerOption[K]
WithLockerKeyCodec overrides automatic lock key serialization.
type Option ¶
type Option[K comparable, V any] func(*config[K, V]) error
Option configures Memcached serialization.
func WithKeyCodec ¶
func WithKeyCodec[K comparable, V any](codec cache.Codec[K]) Option[K, V]
WithKeyCodec overrides automatic key serialization.
func WithValueCodec ¶
func WithValueCodec[K comparable, V any](codec cache.Codec[V]) Option[K, V]
WithValueCodec overrides automatic value serialization.
type Store ¶
type Store[K comparable, V any] struct { // contains filtered or unexported fields }
Store persists entries in Memcached. The caller retains ownership of the client.
func New ¶
func New[K comparable, V any](client *memcache.Client, options ...Option[K, V]) (*Store[K, V], error)
New constructs a Memcached store using a caller-owned client.
func (*Store[K, V]) Get ¶
func (s *Store[K, V]) Get(ctx context.Context, namespace string, key K) (cache.Entry[V], bool, error)
Get returns the live entry stored under key in namespace and whether one is present. Expired entries and entries written before the namespace's last InvalidateAll are reported as absent.
func (*Store[K, V]) Invalidate ¶
Invalidate removes key from namespace. Removing a missing key is not an error.
func (*Store[K, V]) InvalidateAll ¶
InvalidateAll hides every entry in namespace by advancing the namespace generation. Older records are ignored on read and left to expire or be overwritten.