package autobatch

import "github.com/ipfs/go-datastore/autobatch"

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

Index

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(ctx context.Context, k ds.Key) error

Delete deletes a key/value

func (*Datastore) DiskUsage

func (d *Datastore) DiskUsage(ctx context.Context) (uint64, error)

DiskUsage implements the PersistentDatastore interface.

func (*Datastore) Flush

func (d *Datastore) Flush(ctx context.Context) error

Flush flushes the current batch to the underlying datastore.

func (*Datastore) Get

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

Get retrieves a value given a key.

func (*Datastore) GetSize

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

GetSize implements Datastore.GetSize

func (*Datastore) Has

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

Has checks if a key is stored.

func (*Datastore) Put

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

Put stores a key/value.

func (*Datastore) Query

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

Query performs a query

func (*Datastore) Sync

func (d *Datastore) Sync(ctx context.Context, prefix ds.Key) error

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

Source Files

autobatch.go

Version
v0.8.2 (latest)
Published
Mar 4, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
1 month ago

Tools for package owners.