Documentation
¶
Index ¶
- type Codec
- type Config
- type Option
- type Store
- func (s *Store[T]) Delete(ctx context.Context, key string) error
- func (s *Store[T]) Exists(ctx context.Context, key string) (bool, error)
- func (s *Store[T]) ExistsWithPrefix(ctx context.Context, keyPrefix string) (bool, error)
- func (s *Store[T]) Get(ctx context.Context, key string) (T, error)
- func (s *Store[T]) GetAny(ctx context.Context, keyPrefix string) (T, error)
- func (s *Store[T]) GetAnyMatching(ctx context.Context, keyPrefix string, match func(T) bool) (T, error)
- func (s *Store[T]) ListPrefix(ctx context.Context, keyPrefix string) iter.Seq2[T, error]
- func (s *Store[T]) Put(ctx context.Context, key string, value T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds configuration options for a generic store.
type Option ¶
type Option func(*Config)
Option is a functional option for configuring a generic store.
func WithNamespace ¶
WithNamespace sets a key namespace that is prepended to all keys. This is useful when multiple logical stores share a single bucket.
type Store ¶
type Store[T any] struct { // contains filtered or unexported fields }
Store is a generic key-value store backed by a ListableStore.
func New ¶
func New[T any](backend objectstore.ListableStore, codec Codec[T], opts ...Option) *Store[T]
New creates a new generic store. By default, no namespace is used. Use WithNamespace to add a key namespace when multiple stores share the same backend.
func (*Store[T]) ExistsWithPrefix ¶
ExistsWithPrefix checks if any key with the given prefix exists.
func (*Store[T]) GetAny ¶
GetAny retrieves any value matching the given key prefix. Returns store.ErrNotFound if no matching key exists.
func (*Store[T]) GetAnyMatching ¶
func (s *Store[T]) GetAnyMatching(ctx context.Context, keyPrefix string, match func(T) bool) (T, error)
GetAnyMatching retrieves the first value matching the key prefix where the predicate returns true. If match is nil, returns the first value found (equivalent to GetAny). Returns store.ErrNotFound if no matching value exists.
func (*Store[T]) ListPrefix ¶
ListPrefix returns an iterator over all values with the given key prefix.