Documentation
¶
Overview ¶
Package keyspace provides typed, namespaced key partitions for Grove KV.
A Keyspace[T] binds a key prefix, codec, and TTL policy to a Go type, providing type-safe Get/Set operations with automatic serialization.
users := keyspace.New[User](store, "users",
keyspace.WithTTL(24 * time.Hour),
keyspace.WithCodec(codec.MsgPack()),
)
user, err := users.Get(ctx, "u_12345")
err = users.Set(ctx, "u_12345", user)
Index ¶
- func ComposeKey(separator string, segments ...string) string
- func Join(segments ...string) string
- func ParseKey(key, separator string) []string
- type Keyspace
- func (ks *Keyspace[T]) Delete(ctx context.Context, keys ...string) error
- func (ks *Keyspace[T]) Exists(ctx context.Context, keys ...string) (int64, error)
- func (ks *Keyspace[T]) Get(ctx context.Context, key string) (T, error)
- func (ks *Keyspace[T]) GetEntry(ctx context.Context, key string) (*kv.Entry[T], error)
- func (ks *Keyspace[T]) MGet(ctx context.Context, keys []string) (map[string]T, error)
- func (ks *Keyspace[T]) Prefix() string
- func (ks *Keyspace[T]) Scan(ctx context.Context, pattern string, fn func(key string) error) error
- func (ks *Keyspace[T]) Set(ctx context.Context, key string, value T, opts ...kv.SetOption) error
- func (ks *Keyspace[T]) Store() *kv.Store
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComposeKey ¶
ComposeKey builds a composite key from segments joined by the given separator.
Types ¶
type Keyspace ¶
type Keyspace[T any] struct { // contains filtered or unexported fields }
Keyspace is a typed, namespaced partition of a KV store. All keys are automatically prefixed with the keyspace prefix + separator.
func (*Keyspace[T]) Get ¶
Get retrieves and decodes the value for the given key within this keyspace.
func (*Keyspace[T]) GetEntry ¶
GetEntry retrieves the value with full metadata (TTL, version, etc.).
func (*Keyspace[T]) Scan ¶
Scan iterates over keys within this keyspace matching the given pattern suffix.
Click to show internal directories.
Click to hide internal directories.