filekv

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KV_STORE_LOG_SRC  = "kv"
	BBOLT_FILE_FPERMS = 0700
)

Variables

View Source
var (
	ErrInvalidPathKey    = errors.New("invalid path used as local database key")
	ErrKeyAlreadyPresent = errors.New("key already present")
	ErrClosedKvStore     = errors.New("closed KV store")
	ErrEntryNotFound     = errors.New("entry not found")
	ErrOpenKvStore       = errors.New("KV store is already open")

	BBOLT_DATA_BUCKET = []byte("data")

	JSON_SERIALIZATION_CONFIG = core.JSONSerializationConfig{ReprConfig: core.ALL_VISIBLE_REPR_CONFIG}
)

Functions

This section is empty.

Types

type KVTx

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

func NewDatabaseTxIL

func NewDatabaseTxIL(tx *bbolt.Tx) *KVTx

func (*KVTx) Delete

func (tx *KVTx) Delete(ctx *core.Context, key core.Path) error

func (*KVTx) Get

func (tx *KVTx) Get(ctx *core.Context, key core.Path) (result core.Value, valueFound core.Bool, finalErr error)

func (*KVTx) GetSerialized

func (tx *KVTx) GetSerialized(ctx *core.Context, key core.Path) (result string, valueFound core.Bool, finalErr error)

func (*KVTx) Insert

func (tx *KVTx) Insert(ctx *core.Context, key core.Path, value core.Serializable) error

func (*KVTx) InsertSerialized

func (tx *KVTx) InsertSerialized(ctx *core.Context, key core.Path, serialized string) error

func (*KVTx) Set

func (tx *KVTx) Set(ctx *core.Context, key core.Path, value core.Serializable) error

func (*KVTx) SetSerialized

func (tx *KVTx) SetSerialized(ctx *core.Context, key core.Path, serialized string) error

type KvStoreConfig

type KvStoreConfig struct {
	Path core.Path
}

type SerializedValueStorageAdapter

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

func NewSerializedValueStorage

func NewSerializedValueStorage(kv *SingleFileKV, url core.URL) *SerializedValueStorageAdapter

func (*SerializedValueStorageAdapter) BaseURL

func (a *SerializedValueStorageAdapter) BaseURL() core.URL

func (*SerializedValueStorageAdapter) GetSerialized

func (a *SerializedValueStorageAdapter) GetSerialized(ctx *core.Context, key core.Path) (string, bool)

func (SerializedValueStorageAdapter) Has

func (*SerializedValueStorageAdapter) InsertSerialized

func (a *SerializedValueStorageAdapter) InsertSerialized(ctx *core.Context, key core.Path, serialized string)

func (*SerializedValueStorageAdapter) SetSerialized

func (a *SerializedValueStorageAdapter) SetSerialized(ctx *core.Context, key core.Path, serialized string)

SetSerialized implements core.SerializedValueStorage.

type SingleFileKV

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

A SingleFileKV is a key-value store that uses a Bbolt database under the hood, therefore data is stored on a single on-disk file.

func OpenSingleFileKV

func OpenSingleFileKV(config KvStoreConfig) (_ *SingleFileKV, finalErr error)

func (*SingleFileKV) Close

func (kv *SingleFileKV) Close(ctx *core.Context) (bboltError error)

func (*SingleFileKV) Delete

func (kv *SingleFileKV) Delete(ctx *core.Context, key core.Path, db any)

func (*SingleFileKV) ForEach

func (kv *SingleFileKV) ForEach(ctx *core.Context, fn func(key core.Path, getVal func() core.Value) error, db any) error

ForEach calls a function for each item in the database, the provided getVal function should not be stored as it only returns the value at the time of the iteration.

func (*SingleFileKV) Get

func (kv *SingleFileKV) Get(ctx *core.Context, key core.Path, db any) (core.Value, core.Bool, error)

func (*SingleFileKV) GetSerialized

func (kv *SingleFileKV) GetSerialized(ctx *core.Context, key core.Path, db any) (string, core.Bool, error)

func (*SingleFileKV) Has

func (kv *SingleFileKV) Has(ctx *core.Context, key core.Path, db any) core.Bool

func (*SingleFileKV) Insert

func (kv *SingleFileKV) Insert(ctx *core.Context, key core.Path, value core.Serializable, db any)

func (*SingleFileKV) InsertSerialized

func (kv *SingleFileKV) InsertSerialized(ctx *core.Context, key core.Path, serialized string, db any)

func (*SingleFileKV) Set

func (kv *SingleFileKV) Set(ctx *core.Context, key core.Path, value core.Serializable, db any)

func (*SingleFileKV) SetSerialized

func (kv *SingleFileKV) SetSerialized(ctx *core.Context, key core.Path, serialized string, db any)

func (*SingleFileKV) UpdateNoCtx

func (kv *SingleFileKV) UpdateNoCtx(fn func(dbTx *KVTx) error) error

Jump to

Keyboard shortcuts

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