disk

package
v0.0.2-0...-7066471 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrNotFound       = errors.New("not found")
	ErrNoData         = errors.New("no data")
)

Functions

This section is empty.

Types

type BBoltDB

type BBoltDB struct {
	sync.RWMutex
	BucketName string
	// contains filtered or unexported fields
}

BBoltDB - represents a bbolt db implementation

func OpenBoltDBB

func OpenBoltDBB(path string) (*BBoltDB, error)

OpenBoltDB - Opens the specified path

func (*BBoltDB) Close

func (b *BBoltDB) Close()

Close ...

func (*BBoltDB) Del

func (b *BBoltDB) Del(key string) error

Del - removes key from the store

func (*BBoltDB) Empty

func (b *BBoltDB) Empty() (bool, error)

func (*BBoltDB) GC

func (b *BBoltDB) GC() error

GC - runs the garbage collector

func (*BBoltDB) Get

func (b *BBoltDB) Get(k string) ([]byte, error)

Get - fetches the value of the specified k

func (*BBoltDB) Incr

func (b *BBoltDB) Incr(k string, by int64) (int64, error)

Incr - increment the key by the specified value

func (*BBoltDB) MDel

func (b *BBoltDB) MDel(keys []string) error

MDel - removes key(s) from the store

func (*BBoltDB) MGet

func (b *BBoltDB) MGet(keys []string) [][]byte

MGet - fetch multiple values of the specified keys

func (*BBoltDB) MSet

func (b *BBoltDB) MSet(data map[string][]byte) error

MSet - sets multiple key-value pairs

func (*BBoltDB) Scan

func (b *BBoltDB) Scan(scannerOpt ScannerOptions) error

Scan - iterate over the whole store using the handler function

func (*BBoltDB) Set

func (b *BBoltDB) Set(k string, v []byte, ttl time.Duration) error

Set - sets a key with the specified value and optional ttl

func (*BBoltDB) Size

func (b *BBoltDB) Size() int64

Size - returns the size of the database in bytes

func (*BBoltDB) TTL

func (b *BBoltDB) TTL(key string) int64

TTL - returns the time to live of the specified key's value

type BadgerDB

type BadgerDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

BadgerDB - represents a badger db implementation

func OpenBadgerDB

func OpenBadgerDB(path string) (*BadgerDB, error)

OpenPogrebDB - Opens the specified path

func (*BadgerDB) Close

func (bdb *BadgerDB) Close()

Close ...

func (*BadgerDB) Del

func (bdb *BadgerDB) Del(key string) error

Del - removes key from the store

func (*BadgerDB) Empty

func (bdb *BadgerDB) Empty() (bool, error)

func (*BadgerDB) GC

func (bdb *BadgerDB) GC() error

GC - runs the garbage collector

func (*BadgerDB) Get

func (bdb *BadgerDB) Get(k string) ([]byte, error)

Get - fetches the value of the specified k

func (*BadgerDB) Incr

func (bdb *BadgerDB) Incr(k string, by int64) (int64, error)

Incr - increment the key by the specified value

func (*BadgerDB) MDel

func (bdb *BadgerDB) MDel(keys []string) error

MDel - removes key(s) from the store

func (*BadgerDB) MGet

func (bdb *BadgerDB) MGet(keys []string) [][]byte

MGet - fetch multiple values of the specified keys

func (*BadgerDB) MSet

func (bdb *BadgerDB) MSet(data map[string][]byte) error

MSet - sets multiple key-value pairs

func (*BadgerDB) Scan

func (bdb *BadgerDB) Scan(scannerOpt ScannerOptions) error

Scan - iterate over the whole store using the handler function

func (*BadgerDB) Set

func (bdb *BadgerDB) Set(k string, v []byte, ttl time.Duration) error

Set - sets a key with the specified value and optional ttl

func (*BadgerDB) Size

func (bdb *BadgerDB) Size() int64

Size - returns the size of the database in bytes

func (*BadgerDB) TTL

func (bdb *BadgerDB) TTL(key string) int64

TTL - returns the time to live of the specified key's value

type DB

type DB interface {
	Incr(k string, by int64) (int64, error)
	Set(k string, v []byte, ttl time.Duration) error
	MSet(data map[string][]byte) error
	Get(k string) ([]byte, error)
	MGet(keys []string) [][]byte
	TTL(key string) int64
	MDel(keys []string) error
	Del(key string) error
	Scan(ScannerOpt ScannerOptions) error
	Empty() (bool, error)
	Size() int64
	GC() error
	Close()
}

DB Interface

type LevelDB

type LevelDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LevelDB - represents a leveldb db implementation

func OpenLevelDB

func OpenLevelDB(path string) (*LevelDB, error)

OpenLevelDB - Opens the specified path

func (*LevelDB) Close

func (ldb *LevelDB) Close()

Close ...

func (*LevelDB) Del

func (ldb *LevelDB) Del(key string) error

Del - removes key from the store

func (*LevelDB) Empty

func (ldb *LevelDB) Empty() (bool, error)

empty

func (*LevelDB) GC

func (ldb *LevelDB) GC() error

GC - runs the garbage collector

func (*LevelDB) Get

func (ldb *LevelDB) Get(k string) ([]byte, error)

Get - fetches the value of the specified k

func (*LevelDB) Incr

func (ldb *LevelDB) Incr(k string, by int64) (int64, error)

Incr - increment the key by the specified value

func (*LevelDB) MDel

func (ldb *LevelDB) MDel(keys []string) error

MDel - removes key(s) from the store

func (*LevelDB) MGet

func (ldb *LevelDB) MGet(keys []string) [][]byte

MGet - fetch multiple values of the specified keys

func (*LevelDB) MSet

func (ldb *LevelDB) MSet(data map[string][]byte) error

MSet - sets multiple key-value pairs

func (*LevelDB) Scan

func (ldb *LevelDB) Scan(scannerOpt ScannerOptions) error

Scan - iterate over the whole store using the handler function

func (*LevelDB) Set

func (ldb *LevelDB) Set(k string, v []byte, ttl time.Duration) error

Set - sets a key with the specified value and optional ttl

func (*LevelDB) Size

func (ldb *LevelDB) Size() int64

Size - returns the size of the database in bytes

func (*LevelDB) TTL

func (ldb *LevelDB) TTL(key string) int64

TTL - returns the time to live of the specified key's value

type PogrebDB

type PogrebDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PogrebDB - represents a pogreb db implementation

func OpenPogrebDB

func OpenPogrebDB(path string) (*PogrebDB, error)

OpenPogrebDB - Opens the specified path

func (*PogrebDB) Close

func (pdb *PogrebDB) Close()

Close ...

func (*PogrebDB) Del

func (pdb *PogrebDB) Del(key string) error

Del - removes key from the store

func (*PogrebDB) Empty

func (pdb *PogrebDB) Empty() (bool, error)

func (*PogrebDB) GC

func (pdb *PogrebDB) GC() error

GC - runs the garbage collector

func (*PogrebDB) Get

func (pdb *PogrebDB) Get(k string) ([]byte, error)

Get - fetches the value of the specified k

func (*PogrebDB) Incr

func (pdb *PogrebDB) Incr(k string, by int64) (int64, error)

Incr - increment the key by the specified value

func (*PogrebDB) MDel

func (pdb *PogrebDB) MDel(keys []string) error

MDel - removes key(s) from the store

func (*PogrebDB) MGet

func (pdb *PogrebDB) MGet(keys []string) [][]byte

MGet - fetch multiple values of the specified keys

func (*PogrebDB) MSet

func (pdb *PogrebDB) MSet(data map[string][]byte) error

MSet - sets multiple key-value pairs

func (*PogrebDB) Scan

func (pdb *PogrebDB) Scan(scannerOpt ScannerOptions) error

Scan - iterate over the whole store using the handler function

func (*PogrebDB) Set

func (pdb *PogrebDB) Set(k string, v []byte, ttl time.Duration) error

Set - sets a key with the specified value and optional ttl

func (*PogrebDB) Size

func (pdb *PogrebDB) Size() int64

Size - returns the size of the database in bytes

func (*PogrebDB) TTL

func (pdb *PogrebDB) TTL(key string) int64

TTL - returns the time to live of the specified key's value

type ScannerOptions

type ScannerOptions struct {
	// from where to start
	Offset string

	// whether to include the value of the offset in the result or not
	IncludeOffset bool

	// the prefix that must be exists in each key in the iteration
	Prefix string

	// fetch the values (true) or this is a key only iteration (false)
	FetchValues bool

	// the handler that handles the incoming data
	Handler func(k []byte, v []byte) error
}

ScannerOptions - represents the options for a scanner

Jump to

Keyboard shortcuts

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