ultimate_keystore

package module
v0.0.0-...-7c9a615 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 6 Imported by: 0

README

Ultimate Keystore

ultimate_keystore is a Go package that provides a multi-data-type abstraction layer over a raw Key-Value storage engine (specifically ultimate_db.KVStore). It enables high-level data structures similar to Redis, including strings, hashes, lists, and sets, all operating within transactional boundaries.

Features

  • Transactional Support: Uses transactional handles for atomic operations.

  • Data Structures:

  • Strings: Basic Set, Get, and Incr functionality.

  • Hashes: Map-like storage with HSet, HGet, HDel, and HGetAll.

  • Lists: Double-ended queue operations (LPush, RPush, LPop, RPop).

  • Sets: Unique member collections using SAdd, SRem, and SMembers.

  • Key Encoding: Automatic prefixing and serialization to manage different data types and complex structures within a single flat key-value namespace.

Installation

This package requires https://github.com/0TrustCloud/ultimate_db.

go get github.com/0TrustCloud/ultimate_db

Usage

Initialize the keystore by passing in your existing ultimate_db.KVStore instance.

import "github.com/0TrustCloud/ultimate_keystore"

// Assuming 'store' is an instance of ultimate_db.KVStore
ks := ultimate_keystore.NewKeystore(store)

// Begin a transaction
txn := ks.Begin()
defer txn.Abort()

// Perform operations
err := ks.Set(txn, []byte("mykey"), []byte("myvalue"), 0)
if err != nil {
    // handle error
}

// Commit changes
err = txn.Commit()

Testing

The logic within engine.go is verified via unit tests found in kestote_test.go, which utilize mock implementations of the ultimate_db interfaces. You can run these tests using the standard Go toolchain:

go test -v .

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongType   = errors.New("WRONGTYPE Operation against a key holding the wrong kind of value")
	ErrKeyNotFound = errors.New("ERR no such key")
	ErrNoSuchField = errors.New("ERR no such field")
)

Functions

This section is empty.

Types

type Keystore

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

Keystore abstracts multi-data-type operations over a raw KV engine.

func NewKeystore

func NewKeystore(store ultimate_db.KVStore) *Keystore

func (*Keystore) Begin

func (k *Keystore) Begin() *Txn

func (*Keystore) Get

func (k *Keystore) Get(txn *Txn, key []byte) ([]byte, error)

func (*Keystore) HDel

func (k *Keystore) HDel(txn *Txn, key, field []byte) error

func (*Keystore) HGet

func (k *Keystore) HGet(txn *Txn, key, field []byte) ([]byte, error)

func (*Keystore) HGetAll

func (k *Keystore) HGetAll(txn *Txn, key []byte) (map[string][]byte, error)

func (*Keystore) HSet

func (k *Keystore) HSet(txn *Txn, key, field, value []byte) error

func (*Keystore) Incr

func (k *Keystore) Incr(txn *Txn, key []byte) (int64, error)

func (*Keystore) LPop

func (k *Keystore) LPop(txn *Txn, key []byte) ([]byte, error)

func (*Keystore) LPush

func (k *Keystore) LPush(txn *Txn, key []byte, value []byte) error

func (*Keystore) RPop

func (k *Keystore) RPop(txn *Txn, key []byte) ([]byte, error)

func (*Keystore) RPush

func (k *Keystore) RPush(txn *Txn, key []byte, value []byte) error

func (*Keystore) SAdd

func (k *Keystore) SAdd(txn *Txn, key, member []byte) (int, error)

func (*Keystore) SMembers

func (k *Keystore) SMembers(txn *Txn, key []byte) ([][]byte, error)

func (*Keystore) SRem

func (k *Keystore) SRem(txn *Txn, key, member []byte) (int, error)

func (*Keystore) Set

func (k *Keystore) Set(txn *Txn, key []byte, value []byte, ttl time.Duration) error

type Txn

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

func (*Txn) Abort

func (t *Txn) Abort() error

func (*Txn) Commit

func (t *Txn) Commit() error

func (*Txn) ID

func (t *Txn) ID() uint64

Jump to

Keyboard shortcuts

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