memcachedstore

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package memcachedstore provides a store.KV session backend built on the native celeris driver/memcached client. A drop-in rival to the Redis-backed middleware/session/redisstore for deployments that prefer memcached.

Memcached has no key-enumeration protocol (no SCAN), so the returned store implements store.KV only — not store.Scanner or store.PrefixDeleter. The session middleware's Reset path becomes a documented no-op with memcached; callers who need bulk-expiry can call [memcached.Client.Flush] directly or shard sessions across a short-lived prefix they retire by rotating the prefix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// KeyPrefix is prepended to every session id. Memcached keys must
	// be 1..250 bytes with no whitespace/control bytes, so callers
	// should pick a short prefix. Default: "sess:".
	KeyPrefix string
}

Options configure the memcached-backed session store.

type Store

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

Store is a store.KV backed by a *celmc.Client.

func New

func New(client *celmc.Client, opts ...Options) *Store

New returns a new memcached-backed session store.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

Delete implements store.KV. Memcached's DELETE returns ErrCacheMiss when the key is absent; we treat that as a successful no-op to match the store.KV contract ("Delete returning nil means the key is not present regardless of whether it was present before the call").

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) ([]byte, error)

Get implements store.KV.

func (*Store) Set

func (s *Store) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

Set implements store.KV. ttl <= 0 means "no expiry" from memcached's perspective (0 is the magic "never expire" value).

Jump to

Keyboard shortcuts

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