Documentation
¶
Overview ¶
Package redis provides a Redis-backed implementation of ports/kv.Store and an ES es.Snapshotter built on top of it.
Usage:
client := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
snapshotter, err := clstrredis.NewSnapshotter(clstrredis.Config{
Client: client,
KeyPrefix: "myapp:account-123",
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSnapshotter ¶
func NewSnapshotter(cfg Config) (*es.KeyValueSnapshotter, error)
NewSnapshotter creates an ES snapshotter backed by Redis. It wraps a KvStore in es.NewKeyValueSnapshotter, providing the same interface as the NATS-backed snapshotter but storing snapshots in Redis instead of NATS JetStream KV — reducing JetStream load under high concurrency.
func NewTestClient ¶
NewTestClient spins up a redis:7-alpine testcontainer and returns a connected *redis.Client. The container is terminated automatically via t.Cleanup.
Types ¶
type Config ¶
type Config struct {
// Client is the Redis client to use. Required.
Client *redis.Client
// KeyPrefix is an optional namespace prefix prepended to every key as
// "{prefix}:{key}". Use it to isolate stores sharing the same Redis
// instance, e.g. "acd-snapshots:account-abc123".
KeyPrefix string
}
Config holds the configuration for a Redis-backed KV store.
type KvStore ¶
type KvStore struct {
// contains filtered or unexported fields
}
KvStore implements kv.Store backed by Redis.
func NewKvStore ¶
NewKvStore creates a new Redis-backed KV store from cfg. Returns an error if cfg.Client is nil.
func (*KvStore) Get ¶
Get retrieves the entry stored under key. Returns kv.ErrNotFound when the key does not exist or has expired.