remotekv

package
v0.0.0-...-f179113 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package remotekv contains remote key-value storage interfaces, helpers, and implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a local cache implementation of the Interface interface.

func NewCache

func NewCache(c *CacheConfig) (kv *Cache)

NewCache returns a new *Cache. c must not be nil.

func (*Cache) Get

func (kv *Cache) Get(ctx context.Context, key string) (val []byte, ok bool, err error)

Get implements the Interface interface for *Cache.

func (*Cache) Set

func (kv *Cache) Set(ctx context.Context, key string, val []byte) (err error)

Set implements the Interface interface for *Cache.

type CacheConfig

type CacheConfig struct {
	// Cache is the underlying cache.
	Cache agdcache.Interface[string, []byte]
}

CacheConfig is the configuration for the local cache Interface implementation. All fields must not be empty.

type Empty

type Empty struct{}

Empty is the Interface implementation that does nothing.

func (Empty) Get

func (Empty) Get(_ context.Context, _ string) (val []byte, ok bool, err error)

Get implements the Interface interface for Empty. ok is always false.

func (Empty) Set

func (Empty) Set(_ context.Context, _ string, _ []byte) (err error)

Set implements the Interface interface for Empty.

type Interface

type Interface interface {
	// Get returns val by key from the storage.  ok is true if val by key
	// exists.
	Get(ctx context.Context, key string) (val []byte, ok bool, err error)

	// Set sets val into the storage by key.
	Set(ctx context.Context, key string, val []byte) (err error)
}

Interface is the remote key-value storage interface.

type KeyNamespace

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

KeyNamespace is wrapper around Interface that adds a custom prefix to the keys.

func NewKeyNamespace

func NewKeyNamespace(conf *KeyNamespaceConfig) (n *KeyNamespace)

NewKeyNamespace returns a properly initialized *KeyNamespace. conf must not be nil.

func (*KeyNamespace) Get

func (n *KeyNamespace) Get(ctx context.Context, key string) (val []byte, ok bool, err error)

Get implements the Interface interface for *KeyNamespace.

func (*KeyNamespace) Set

func (n *KeyNamespace) Set(ctx context.Context, key string, val []byte) (err error)

Set implements the Interface interface for *KeyNamespace.

type KeyNamespaceConfig

type KeyNamespaceConfig struct {
	// KV is the key-value storage to be wrapped.  It must not be nil.
	KV Interface

	// Prefix is the custom prefix to be added to the keys.  Prefix should be in
	// accordance with the wrapped KV storage keys.
	Prefix string
}

KeyNamespaceConfig is the configuration structure for KeyNamespace.

Directories

Path Synopsis
Package consulkv contains implementation of remotekv.Interface for Consul key-value storage.
Package consulkv contains implementation of remotekv.Interface for Consul key-value storage.
Package rediskv contains implementation of remotekv.Interface for Redis.
Package rediskv contains implementation of remotekv.Interface for Redis.

Jump to

Keyboard shortcuts

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