db

package
v0.0.0-...-9cc7e76 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGetRoot    = errors.New("cannot get from root")
	ErrDeleteRoot = errors.New("cannot delete from root")
	ErrorPutRoot  = errors.New("cannot put from root")
)

Functions

This section is empty.

Types

type BboltDBKVStore

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

func NewBboltDBKVStore

func NewBboltDBKVStore(dbPath string, cache Cache) *BboltDBKVStore

func (*BboltDBKVStore) Bucket

func (b *BboltDBKVStore) Bucket(prefix string) (KVStore, error)

func (*BboltDBKVStore) Close

func (b *BboltDBKVStore) Close() error

func (*BboltDBKVStore) Delete

func (b *BboltDBKVStore) Delete(key []byte) error

func (*BboltDBKVStore) Get

func (b *BboltDBKVStore) Get(key []byte) ([]byte, error)

func (*BboltDBKVStore) Open

func (b *BboltDBKVStore) Open() error

func (*BboltDBKVStore) Put

func (b *BboltDBKVStore) Put(key []byte, value []byte) error

type Cache

type Cache interface {
	Get(key []byte) ([]byte, bool)
	Put(key []byte, value []byte)
	Delete(key []byte)
}

type EtcdKVStore

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

EtcdKVStore is an implementation of the KVStore interface using etcd.

func NewEtcdKVStore

func NewEtcdKVStore(client *clientv3.Client, prefix string, cache Cache, timeout time.Duration) *EtcdKVStore

NewEtcdKVStore creates a new instance of EtcdKVStore.

func (*EtcdKVStore) Bucket

func (e *EtcdKVStore) Bucket(prefix string) (KVStore, error)

Bucket creates a new bucket with the given prefix.

func (*EtcdKVStore) Close

func (e *EtcdKVStore) Close() error

Close closes the connection to the etcd cluster.

func (*EtcdKVStore) Delete

func (e *EtcdKVStore) Delete(key []byte) error

Delete removes the value associated with the given key.

func (*EtcdKVStore) Get

func (e *EtcdKVStore) Get(key []byte) ([]byte, error)

Get retrieves the value associated with the given key.

func (*EtcdKVStore) Open

func (e *EtcdKVStore) Open() error

Open establishes a connection to the etcd cluster.

func (*EtcdKVStore) Put

func (e *EtcdKVStore) Put(key []byte, value []byte) error

Put stores the given key-value pair.

type KVStore

type KVStore interface {
	Open() error
	Close() error
	Get(key []byte) ([]byte, error)
	Put(key []byte, value []byte) error
	Delete(key []byte) error
	Bucket(prefix string) (KVStore, error)
}

type LRUCache

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

LRUCache is an implementation of the Cache interface using an LRU cache.

func NewLRUCache

func NewLRUCache(size int) (*LRUCache, error)

NewLRUCache creates a new instance of LRUCache with the specified size.

func (*LRUCache) Delete

func (c *LRUCache) Delete(key []byte)

Delete removes the value associated with the given key from the cache.

func (*LRUCache) Get

func (c *LRUCache) Get(key []byte) ([]byte, bool)

Get retrieves the value associated with the given key from the cache. It returns the value and a boolean indicating whether the key was found.

func (*LRUCache) Put

func (c *LRUCache) Put(key []byte, value []byte)

Put adds a key-value pair to the cache.

Jump to

Keyboard shortcuts

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