dbolt

package module
v0.0.0-...-21c8821 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 16 Imported by: 0

README

Documentation

Index

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

func (*Counter) MarshalJSON

func (c *Counter) MarshalJSON() ([]byte, error)

type Cursor

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

func (*Cursor) Key

func (c *Cursor) Key() []byte

func (*Cursor) Next

func (c *Cursor) Next() ([]byte, []byte)

func (*Cursor) Seek

func (c *Cursor) Seek(key []byte) ([]byte, []byte)

func (*Cursor) SeekToFirst

func (c *Cursor) SeekToFirst() ([]byte, []byte)

func (*Cursor) Value

func (c *Cursor) Value() []byte

type KV

type KV struct {
	Path  string
	Fsync func(int) error // overridable; for testing
	// contains filtered or unexported fields
}

func Open

func Open(fp string) (*KV, error)

Open opens the DB.

func (*KV) Begin

func (db *KV) Begin(writable bool) *Tx

func (*KV) Close

func (db *KV) Close()

Close cleanups all mmap chunks and close the files

func (*KV) Open

func (db *KV) Open() error

open or create a DB file

func (*KV) Update

func (db *KV) Update(fn func(tx *Tx) error) error

Update is a helper to open a write transaction.

func (*KV) View

func (db *KV) View(fn func(tx *Tx) error) error

View is a helper to open a read-only transaction.

type Tx

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

func NewTx

func NewTx(db *KV, writable bool) *Tx

func (*Tx) Commit

func (t *Tx) Commit() error

Commit commits the transaction. if the transaction is writable, the changes are committed to the disk. if the transaction is readonly, same as Rollback.

func (*Tx) Cursor

func (t *Tx) Cursor() *Cursor

Cursor returns a new cursor on this transaction. invalid after this transaction is committed or rolled back.

func (*Tx) Del

func (t *Tx) Del(key []byte) (bool, error)

Del deletes the value for the given key.

func (*Tx) Get

func (t *Tx) Get(key []byte) ([]byte, bool)

Get returns the value for the given key.

func (*Tx) Rollback

func (t *Tx) Rollback() error

Rollback rolls back the transaction.

func (*Tx) Set

func (t *Tx) Set(key []byte, val []byte) error

Set sets the value for the given key.

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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