memory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package memory contains in-memory reference implementation of bitempura.DB

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func NewDB

func NewDB(versionedKVs ...*bt.VersionedKV) (*DB, error)

NewDB constructs a in-memory bitemporal DB.

The database may optionally be seeded with "versioned key-value" records. No two records for the same key may overlap both transaction time and valid time. Transaction times (which normally default to now) may optionally be controlled with SetNow.

func (*DB) Delete

func (db *DB) Delete(key string, opts ...bt.WriteOpt) error

Delete removes value (with optional start and end valid time).

func (*DB) Get

func (db *DB) Get(key string, opts ...bt.ReadOpt) (*bt.VersionedKV, error)

Get data by key (as of optional valid and transaction times).

func (*DB) History

func (db *DB) History(key string) ([]*bt.VersionedKV, error)

History returns versions by descending end transaction time, descending end valid time

func (*DB) List

func (db *DB) List(opts ...bt.ReadOpt) ([]*bt.VersionedKV, error)

List all data (as of optional valid and transaction times).

func (*DB) Set

func (db *DB) Set(key string, value bt.Value, opts ...bt.WriteOpt) error

Set stores value (with optional start and end valid time).

func (*DB) SetNow

func (db *DB) SetNow(t time.Time)

SetNow overrides "now" used by the DB for transaction times. By default, DB uses time.Now(). If SetNow is used, the DB will stop defaulting to time.Now() for all future uses.

Jump to

Keyboard shortcuts

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