kv

package
v0.0.0-...-70d0519 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package kv provides an interface and implementations for key-value stores. It includes an in-memory key-value store and a persistent key-value store using BadgerDB.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound = badger.ErrKeyNotFound
	ErrConflict    = badger.ErrConflict
)

Functions

func NewInMemoryKV

func NewInMemoryKV() notionstix.Store

NewInMemoryKV creates a new instance of InMemoryKV.

func NewPersistentKV

func NewPersistentKV(file string) (notionstix.Store, error)

NewPersistentKV creates a new instance of PersistentKV with the specified file path.

Types

type InMemoryKV

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

InMemoryKV is an in-memory key-value store implementation.

func (*InMemoryKV) Cleanup

func (i *InMemoryKV) Cleanup()

Cleanup performs any necessary cleanup for the in-memory store.

func (*InMemoryKV) Get

func (i *InMemoryKV) Get(key string) ([]byte, error)

Get retrieves the value associated with the given key from the in-memory store.

func (*InMemoryKV) Set

func (i *InMemoryKV) Set(key string, value []byte) error

Set sets the value associated with the given key in the in-memory store.

type PersistentKV

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

PersistentKV is a persistent key-value store implementation using BadgerDB.

func (*PersistentKV) Cleanup

func (p *PersistentKV) Cleanup()

Cleanup performs any necessary cleanup for the persistent store. It runs a value log garbage collection every 15 minutes.

func (*PersistentKV) Get

func (p *PersistentKV) Get(key string) ([]byte, error)

Get retrieves the value associated with the given key from the persistent store.

func (*PersistentKV) Set

func (p *PersistentKV) Set(key string, value []byte) error

Set sets the value associated with the given key in the persistent store.

Jump to

Keyboard shortcuts

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