kv

package
v2.9.4 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package kv provides a Key-Value Store interface and a few implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyAfter added in v2.7.0

func KeyAfter(x []byte) []byte

KeyAfter returns a byte slice ordered immediately after x lexicographically the motivating use case is iteration.

func PrefixEnd added in v2.7.0

func PrefixEnd(prefix []byte) []byte

PrefixEnd returns the key > all the keys with prefix p, but < any other key

func TestStore added in v2.7.0

func TestStore(t *testing.T, newStore func(t testing.TB) Store)

Types

type BucketStore added in v2.7.0

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

func NewFromBucket added in v2.7.0

func NewFromBucket(b *blob.Bucket, maxKeySize, maxValueSize int) *BucketStore

func (*BucketStore) Delete added in v2.7.0

func (s *BucketStore) Delete(ctx context.Context, key []byte) error

func (*BucketStore) Exists added in v2.7.0

func (s *BucketStore) Exists(ctx context.Context, key []byte) (bool, error)

func (*BucketStore) Get added in v2.7.0

func (s *BucketStore) Get(ctx context.Context, key []byte, buf []byte) (int, error)

func (*BucketStore) NewKeyIterator added in v2.7.0

func (s *BucketStore) NewKeyIterator(span Span) stream.Iterator[[]byte]

func (*BucketStore) Put added in v2.7.0

func (s *BucketStore) Put(ctx context.Context, key []byte, value []byte) error

type Deleter added in v2.7.0

type Deleter interface {
	// Delete removes the entry at key.
	// If there is no entry Delete returns nil
	Delete(ctx context.Context, key []byte) error
}

type FSStore added in v2.7.0

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

func NewFSStore added in v2.7.0

func NewFSStore(dir string, maxKeySize, maxValueSize int) *FSStore

func (*FSStore) Delete added in v2.7.0

func (s *FSStore) Delete(ctx context.Context, key []byte) error

func (*FSStore) Exists added in v2.7.0

func (s *FSStore) Exists(ctx context.Context, key []byte) (bool, error)

func (*FSStore) Get added in v2.7.0

func (s *FSStore) Get(ctx context.Context, key, buf []byte) (_ int, retErr error)

func (*FSStore) NewKeyIterator added in v2.7.0

func (s *FSStore) NewKeyIterator(span Span) stream.Iterator[[]byte]

func (*FSStore) Put added in v2.7.0

func (s *FSStore) Put(ctx context.Context, key, value []byte) (retErr error)

type GetPut

type GetPut interface {
	Getter
	Putter
}

type Getter added in v2.7.0

type Getter interface {
	// Get looks up the value that corresponds to key and write the value into buf.
	// If buf is too small for the value then io.ErrShortBuffer is returned.
	Get(ctx context.Context, key []byte, buf []byte) (int, error)
}

type KeyIterable added in v2.7.0

type KeyIterable interface {
	// NewKeyIterator returns a new iterator which will cover span.
	NewKeyIterator(span Span) stream.Iterator[[]byte]
}

type LRUCache added in v2.7.0

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

func NewLRUCache added in v2.7.0

func NewLRUCache(slow, fast Store, size int) *LRUCache

func (*LRUCache) Delete added in v2.7.0

func (c *LRUCache) Delete(ctx context.Context, key []byte) error

func (*LRUCache) Exists added in v2.7.0

func (c *LRUCache) Exists(ctx context.Context, key []byte) (bool, error)

func (*LRUCache) Get added in v2.7.0

func (c *LRUCache) Get(ctx context.Context, key []byte, buf []byte) (int, error)

func (*LRUCache) NewKeyIterator added in v2.7.0

func (c *LRUCache) NewKeyIterator(span Span) stream.Iterator[[]byte]

func (*LRUCache) Put added in v2.7.0

func (c *LRUCache) Put(ctx context.Context, key, value []byte) error

type MemStore added in v2.7.0

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

MemStore implements an in-memory store

func NewMemStore added in v2.7.0

func NewMemStore() *MemStore

func (*MemStore) Delete added in v2.7.0

func (ms *MemStore) Delete(ctx context.Context, key []byte) error

func (*MemStore) Exists added in v2.7.0

func (ms *MemStore) Exists(ctx context.Context, key []byte) (bool, error)

func (*MemStore) Get added in v2.7.0

func (ms *MemStore) Get(ctx context.Context, key []byte, buf []byte) (int, error)

func (*MemStore) NewKeyIterator added in v2.7.0

func (ms *MemStore) NewKeyIterator(span Span) stream.Iterator[[]byte]

func (*MemStore) Put added in v2.7.0

func (ms *MemStore) Put(ctx context.Context, key, value []byte) error

type Pool added in v2.7.0

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

Pool manages a pool of buffers, all the same size.

The pointer to slice stuff is to make the linter happy.

func NewPool added in v2.7.0

func NewPool(maxBufferSize int) *Pool

func (*Pool) GetF added in v2.7.0

func (p *Pool) GetF(ctx context.Context, s Getter, key []byte, cb ValueCallback) error

type Prefixed added in v2.7.0

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

Prefixed is a Store whichs stores entries beneath a prefix in a backing Store.

func NewPrefixed added in v2.7.0

func NewPrefixed(inner Store, prefix []byte) *Prefixed

func (*Prefixed) Delete added in v2.7.0

func (s *Prefixed) Delete(ctx context.Context, key []byte) error

func (*Prefixed) Exists added in v2.7.0

func (s *Prefixed) Exists(ctx context.Context, key []byte) (bool, error)

func (*Prefixed) Get added in v2.7.0

func (s *Prefixed) Get(ctx context.Context, key []byte, buf []byte) (int, error)

func (*Prefixed) NewKeyIterator added in v2.7.0

func (s *Prefixed) NewKeyIterator(span Span) stream.Iterator[[]byte]

func (*Prefixed) Put added in v2.7.0

func (s *Prefixed) Put(ctx context.Context, key []byte, value []byte) error

type Putter added in v2.7.0

type Putter interface {
	// Put creates an entry mapping key to value, overwriting any previous mapping.
	Put(ctx context.Context, key, value []byte) error
}

type Semaphored added in v2.7.0

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

func NewSemaphored added in v2.7.0

func NewSemaphored(inner Store, download, upload int) *Semaphored

func (*Semaphored) Delete added in v2.7.0

func (s *Semaphored) Delete(ctx context.Context, key []byte) error

func (*Semaphored) Exists added in v2.7.0

func (s *Semaphored) Exists(ctx context.Context, key []byte) (bool, error)

func (*Semaphored) Get added in v2.7.0

func (s *Semaphored) Get(ctx context.Context, key, buf []byte) (int, error)

func (*Semaphored) NewKeyIterator added in v2.7.0

func (sem *Semaphored) NewKeyIterator(span Span) stream.Iterator[[]byte]

func (*Semaphored) Put added in v2.7.0

func (s *Semaphored) Put(ctx context.Context, key, value []byte) error

type Span added in v2.7.0

type Span struct {
	Begin []byte
	End   []byte
}

Span is a range of bytes from Begin inclusive to End exclusive As a special case if End == nil, then the span has no upper bound.

func SpanFromPrefix added in v2.7.0

func SpanFromPrefix(prefix []byte) Span

func (Span) Contains added in v2.7.0

func (s Span) Contains(k []byte) bool

Contains returns true if the Span contains k

type Store

type Store interface {
	Getter
	Putter
	Deleter
	Exists(ctx context.Context, key []byte) (bool, error)

	KeyIterable
}

Store is a key-value store

func NewFromObjectClient

func NewFromObjectClient(objC obj.Client, maxKeySize, maxValueSize int) Store

NewFromObjectClient converts an object client into a key value store. This can provide more natural interface for small values, but it will read the entire object into memory

type ValueCallback

type ValueCallback = func([]byte) error

ValueCallback is the type of functions used to access values It is never ok for the callback to retain the data. If it were ok, then the callee would just return the data.

Jump to

Keyboard shortcuts

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