affixed

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package affixed implements a blob.KV that delegates to another implementation, with keys namespaced by a fixed prefix and/or suffix concatenated with each key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CAS

type CAS struct {
	KV
	// contains filtered or unexported fields
}

CAS implements an affixed wrapper around a blob.CAS instance. The resulting store adds designated prefix/suffix strings to the keys delegated to its care.

func NewCAS

func NewCAS(cas blob.CAS) CAS

NewCAS creates a new affixed KV associated with the specified cas. Affixes do not nest: If cas is already an affixed.CAS, it is returned as.is.

func (CAS) Base

func (c CAS) Base() blob.CAS

Base returns the underlying store associated with c.

func (CAS) CASKey

func (c CAS) CASKey(ctx context.Context, opts blob.CASPutOptions) (string, error)

CASKey implements part of the blob.CAS interface.

func (CAS) CASPut

func (c CAS) CASPut(ctx context.Context, opts blob.CASPutOptions) (string, error)

CASPut implements part of the blob.CAS interface.

func (CAS) Derive

func (c CAS) Derive(prefix, suffix string) CAS

Derive creates a clone of c that delegates to the same underlying store, but using a different prefix and suffix. If prefix == suffix == "", Derive returns a store that is equivalent to the original base store.

func (CAS) WithPrefix

func (c CAS) WithPrefix(prefix string) CAS

WithPrefix creates a clone of c that delegates to the same underlying store, but using a different prefix. The suffix, if any, is unchanged.

func (CAS) WithSuffix

func (c CAS) WithSuffix(suffix string) CAS

WithSuffix creates a clone of c that delegates to the same underlying store, but using a different suffix. The prefix, if any, is unchanged.

type KV added in v0.7.0

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

KV implements the blob.KV interface by delegating to an underlying keyspace, but with each key prefixed and/or suffixed by fixed non-empty strings. This allows multiple consumers to share non-overlapping namespaces within a single KV.

func New

func New(kv blob.KV) KV

New creates a KV associated with the specified kv. The initial value is exactly equivalent to the underlying store; use Derive to create clones that use a different prefix/suffix.

Affixes do not nest: If s is already a KV, it is returned as-is.

func (KV) Base added in v0.7.0

func (s KV) Base() blob.KV

Base returns the underlying store associated with s.

func (KV) Delete added in v0.7.0

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

Delete implements part of blob.KV by delegation.

func (KV) Derive added in v0.7.0

func (s KV) Derive(prefix, suffix string) KV

Derive creates a clone of s that delegates to the same underlying store, but using a different prefix and suffix. If prefix == suffix == "", Derive returns a store that is equivalent to the original base store.

func (KV) Get added in v0.7.0

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

Get implements part of blob.Store by delegation.

func (KV) Len added in v0.7.0

func (s KV) Len(ctx context.Context) (int64, error)

Len implements part of blob.KV by delegation. It reports only the number of keys matching the current prefix.

func (KV) List added in v0.7.0

func (s KV) List(ctx context.Context, start string, f func(string) error) error

List implements part of blob.KV by delegation. It filters the underlying list results to include only keys prefixed/suffixed for this store.

func (KV) Prefix added in v0.7.0

func (s KV) Prefix() string

Prefix returns the key prefix associated with s.

func (KV) Put added in v0.7.0

func (s KV) Put(ctx context.Context, opts blob.PutOptions) error

Put implements part of blob.KV by delegation.

func (KV) Suffix added in v0.7.0

func (s KV) Suffix() string

Suffix returns the key suffix associated with s.

func (KV) UnwrapKey added in v0.7.0

func (s KV) UnwrapKey(key string) string

UnwrapKey returns the unwrapped version of key with the current prefix and suffix removed (if present).

func (KV) WithPrefix added in v0.7.0

func (s KV) WithPrefix(prefix string) KV

WithPrefix creates a clone of s that delegates to the same underlying store, but using a different prefix. The suffix, if any, is unchanged.

func (KV) WithSuffix added in v0.7.0

func (s KV) WithSuffix(suffix string) KV

WithSuffix creates a clone of s that delegates to the same underlying store, but using a different suffix. The prefix, if any, is unchanged.

func (KV) WrapKey added in v0.7.0

func (s KV) WrapKey(key string) string

WrapKey returns the wrapped version of key as it would be stored into the base store with the current prefix and suffix attached.

Jump to

Keyboard shortcuts

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