storage

package
v0.0.0-...-41ae9e4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultStorageEngine default storage engine
	DefaultStorageEngine = "ldb"
)

Variables

This section is empty.

Functions

func RegisterStorageEngine

func RegisterStorageEngine(name string, fn func(path string) (Storage, error))

RegisterStorageEngine register Storage engine

Types

type Badger

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

Badger is badger.KV

func (*Badger) Close

func (s *Badger) Close() error

Close closes a KV. It's crucial to call it to ensure all the pending updates make their way to disk.

func (*Badger) Delete

func (s *Badger) Delete(k []byte) error

Delete deletes a key. Exposing this so that user does not have to specify the Entry directly. For example, BitDelete seems internal to badger.

func (*Badger) ForEach

func (s *Badger) ForEach(fn func(k, v []byte) error) error

ForEach get all key and value

func (*Badger) Get

func (s *Badger) Get(k []byte) ([]byte, error)

Get looks for key and returns a value. If key is not found, value is nil.

func (*Badger) Has

func (s *Badger) Has(k []byte) (bool, error)

Has returns true if the DB does contains the given key.

func (*Badger) Set

func (s *Badger) Set(k, v []byte) error

Set sets the provided value for a given key. If key is not present, it is created. If it is present, the existing value is overwritten with the one provided.

func (*Badger) WALName

func (s *Badger) WALName() string

WALName is useless for this kv database

type Storage

type Storage interface {
	Set(k, v []byte) error
	Get(k []byte) ([]byte, error)
	Delete(k []byte) error
	Has(k []byte) (bool, error)
	ForEach(fn func(k, v []byte) error) error
	Close() error
	WALName() string
}

Storage is storage interface

func OpenBadgerStorage

func OpenBadgerStorage(dbPath string) (Storage, error)

OpenBadgerStorage open Badger storage

func OpenBoltStorage

func OpenBoltStorage(dbPath string) (Storage, error)

OpenBoltStorage open Bolt storage

func OpenLeveldbStorage

func OpenLeveldbStorage(dbPath string) (Storage, error)

OpenLeveldbStorage opens or creates a DB for the given storage. The DB will be created if not exist, unless ErrorIfMissing is true. Also, if ErrorIfExist is true and the DB exist Open will returns os.ErrExist error.

func OpenStorage

func OpenStorage(path string, args ...string) (Storage, error)

OpenStorage open Storage engine

Jump to

Keyboard shortcuts

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