mdb

package module
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

README

mdb

An in-process, in-memory database for Go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMismatchedIDs = errors.New("MismatchedIDs")
	ErrDuplicate     = errors.New("Duplicate")
	ErrNotFound      = errors.New("NotFound")
	ErrReadOnly      = errors.New("ReadOnly")

	// Return in update function to abort changes.
	ErrAbortUpdate = errors.New("AbortUpdate")
)

Functions

This section is empty.

Types

type BTreeIndex

type BTreeIndex[T any] struct {
	// contains filtered or unexported fields
}

func NewBTreeIndex

func NewBTreeIndex[T any](
	c *Collection[T],
	less func(*T, *T) bool,
	include func(*T) bool,
) *BTreeIndex[T]

func (*BTreeIndex[T]) Ascend

func (t *BTreeIndex[T]) Ascend() *BTreeIterator[T]

func (*BTreeIndex[T]) AscendAfter

func (t *BTreeIndex[T]) AscendAfter(pivot T) *BTreeIterator[T]

func (*BTreeIndex[T]) Descend

func (t *BTreeIndex[T]) Descend() *BTreeIterator[T]

func (*BTreeIndex[T]) DescendAfter

func (t *BTreeIndex[T]) DescendAfter(pivot T) *BTreeIterator[T]

func (*BTreeIndex[T]) Get

func (t *BTreeIndex[T]) Get(item T) (T, bool)

func (*BTreeIndex[T]) Len

func (t *BTreeIndex[T]) Len() int

func (*BTreeIndex[T]) Max

func (t *BTreeIndex[T]) Max() (item T, ok bool)

func (*BTreeIndex[T]) Min

func (t *BTreeIndex[T]) Min() (item T, ok bool)

type BTreeIterator

type BTreeIterator[T any] struct {
	// contains filtered or unexported fields
}

func (*BTreeIterator[T]) Close

func (iter *BTreeIterator[T]) Close()

func (*BTreeIterator[T]) Next

func (iter *BTreeIterator[T]) Next() bool

func (*BTreeIterator[T]) Value

func (iter *BTreeIterator[T]) Value() T

type Collection

type Collection[T any] struct {
	// contains filtered or unexported fields
}

func NewCollection

func NewCollection[T any](db *Database, name string, getID func(*T) uint64) *Collection[T]

func (Collection[T]) Delete

func (c Collection[T]) Delete(id uint64)

func (Collection[T]) Get

func (c Collection[T]) Get(id uint64) (t T, ok bool)

func (*Collection[T]) Insert

func (c *Collection[T]) Insert(item T) (T, error)

func (*Collection[T]) NextID

func (c *Collection[T]) NextID() uint64

func (*Collection[T]) SetSanitize

func (c *Collection[T]) SetSanitize(sanitize func(*T))

func (*Collection[T]) SetValidate

func (c *Collection[T]) SetValidate(validate func(*T) error)

func (*Collection[T]) Update

func (c *Collection[T]) Update(id uint64, update func(T) (T, error)) error

type Database

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

func NewPrimary

func NewPrimary(root string) *Database

func NewSecondary

func NewSecondary(root string) *Database

func (*Database) CleanBefore added in v1.2.0

func (db *Database) CleanBefore(seconds int64)

CleanBefore deletes log entries that are more than the given number of seconds old.

func (*Database) Close

func (db *Database) Close()

func (*Database) LogInfo added in v1.2.4

func (db *Database) LogInfo() LogInfo

func (*Database) MaxSeqNum

func (db *Database) MaxSeqNum() uint64

func (*Database) Start

func (db *Database) Start()

func (*Database) SyncRecv

func (db *Database) SyncRecv(conn net.Conn)

func (*Database) SyncSend

func (db *Database) SyncSend(conn net.Conn)

type LogInfo added in v1.2.4

type LogInfo = kvstore.LogInfo

type MapIndex

type MapIndex[K comparable, T any] struct {
	// contains filtered or unexported fields
}

func NewMapIndex

func NewMapIndex[K comparable, T any](
	c *Collection[T],
	name string,
	getKey func(*T) K,
	include func(*T) bool,
) *MapIndex[K, T]

func (*MapIndex[K, T]) Delete

func (m *MapIndex[K, T]) Delete(k K)

func (*MapIndex[K, T]) Get

func (m *MapIndex[K, T]) Get(k K) (t T, ok bool)

func (*MapIndex[K, T]) Update

func (m *MapIndex[K, T]) Update(k K, update func(T) (T, error)) error

type WALStatus

type WALStatus struct {
	MaxSeqNumKV  uint64
	MaxSeqNumWAL uint64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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