dsbadger

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("datastore closed")

ErrClosed is an error message returned when the datastore is no longer open

Functions

This section is empty.

Types

type Datastore

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

Datastore satisfies the Datastore::Batching interface using badger

func NewDatastore

func NewDatastore(path string, options *Options) (*Datastore, error)

NewDatastore creates a new badger datastore.

DO NOT set the Dir and/or ValuePath fields of opt, they will be set for you.

func (*Datastore) Batch

func (d *Datastore) Batch() (ds.Batch, error)

Batch is used to return a set of batchable transaction operatiosn

func (*Datastore) Close

func (d *Datastore) Close() error

Close is used to close our datastore and cease operations.

func (*Datastore) CollectGarbage

func (d *Datastore) CollectGarbage() (err error)

CollectGarbage removes garbage from our underlying datastore

func (*Datastore) Delete

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

Delete remove the key+value from our datastore

func (*Datastore) DiskUsage

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

DiskUsage implements the PersistentDatastore interface. It returns the sum of lsm and value log files sizes in bytes.

func (*Datastore) Get

func (d *Datastore) Get(key ds.Key) (value []byte, err error)

Get returns the value associated with the key

func (*Datastore) GetExpiration

func (d *Datastore) GetExpiration(key ds.Key) (time.Time, error)

GetExpiration is used to get the ttl expiration time for the key

func (*Datastore) GetSize

func (d *Datastore) GetSize(key ds.Key) (size int, err error)

GetSize returns the size of value associated with the key

func (*Datastore) Has

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

Has returns whether or not we have the given key in our datastore

func (*Datastore) NewTransaction

func (d *Datastore) NewTransaction(readOnly bool) (ds.Txn, error)

NewTransaction starts a new transaction. The resulting transaction object can be mutated without incurring changes to the underlying Datastore until the transaction is Committed.

func (*Datastore) Put

func (d *Datastore) Put(key ds.Key, value []byte) error

Put stores the value under the given key

func (*Datastore) PutWithTTL

func (d *Datastore) PutWithTTL(key ds.Key, value []byte, ttl time.Duration) error

PutWithTTL puts the value udner the given key for the specific duration before being GC'd

func (*Datastore) Query

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

Query is used to perform a search of the keys and values in our datastore

func (*Datastore) SetTTL

func (d *Datastore) SetTTL(key ds.Key, ttl time.Duration) error

SetTTL is used to override the stored ttl for the given key

func (*Datastore) Sync

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

Sync is used to manually trigger syncing db contents to disk. This call is only usable when synchronous writes aren't enabled

type Options

type Options struct {
	// Please refer to the Badger docs to see what this is for
	GcDiscardRatio float64

	// Interval between GC cycles
	//
	// If zero, the datastore will perform no automatic garbage collection.
	GcInterval time.Duration

	// Sleep time between rounds of a single GC cycle.
	//
	// If zero, the datastore will only perform one round of GC per
	// GcInterval.
	GcSleep time.Duration

	badger.Options
}

Options are the badger datastore options, reexported here for convenience.

var DefaultOptions Options

DefaultOptions are the default options for the badger datastore.

Jump to

Keyboard shortcuts

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