autobatch

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 2 Imported by: 32

README

autobatch

Autobatch is an implementation of go-datastore that automatically batches together writes by holding puts in memory until a certain threshold is met. This can improve disk performance at the cost of memory in certain situations.

Usage

Simply wrap your existing datastore in an autobatching layer like so:

bds := NewAutoBatching(basedstore, 128)

And make all future calls to the autobatching object.

License

MIT

Documentation

Overview

Package autobatch provides a go-datastore implementation that automatically batches together writes by holding puts in memory until a certain threshold is met.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datastore

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

Datastore implements a go-datastore.

func NewAutoBatching

func NewAutoBatching(d ds.Batching, size int) *Datastore

NewAutoBatching returns a new datastore that automatically batches writes using the given Batching datastore. The size of the memory pool is given by size.

func (*Datastore) Close

func (d *Datastore) Close() error

func (*Datastore) Delete

func (d *Datastore) Delete(k ds.Key) error

Delete deletes a key/value

func (*Datastore) DiskUsage

func (d *Datastore) DiskUsage() (uint64, error)

DiskUsage implements the PersistentDatastore interface.

func (*Datastore) Flush

func (d *Datastore) Flush() error

Flush flushes the current batch to the underlying datastore.

func (*Datastore) Get

func (d *Datastore) Get(k ds.Key) ([]byte, error)

Get retrieves a value given a key.

func (*Datastore) GetSize

func (d *Datastore) GetSize(k ds.Key) (int, error)

GetSize implements Datastore.GetSize

func (*Datastore) Has

func (d *Datastore) Has(k ds.Key) (bool, error)

Has checks if a key is stored.

func (*Datastore) Put

func (d *Datastore) Put(k ds.Key, val []byte) error

Put stores a key/value.

func (*Datastore) Query

func (d *Datastore) Query(q dsq.Query) (dsq.Results, error)

Query performs a query

func (*Datastore) Sync added in v0.3.0

func (d *Datastore) Sync(prefix ds.Key) error

Sync flushes all operations on keys at or under the prefix from the current batch to the underlying datastore

Jump to

Keyboard shortcuts

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