disk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Megabyte = 1 << 20

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrNotFound       = errors.New("not found")
	ErrNoData         = errors.New("no data")
	ErrNotSupported   = errors.New("not supported")
)
View Source
var (
	OpenPogrebDB func(string) (DB, error)
)

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) 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 BuntDB

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

BuntDB - represents a BuntDB implementation

func OpenBuntDB

func OpenBuntDB(path string) (*BuntDB, error)

OpenBuntDB - Opens the specified path

func (*BuntDB) Close

func (bdb *BuntDB) Close()

Close

func (*BuntDB) Del

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

Del - removes key from the store

func (*BuntDB) GC

func (bdb *BuntDB) GC() error

GC - runs the garbage collector

func (*BuntDB) Get

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

Get - fetches the value of the specified k

func (*BuntDB) Incr

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

Incr - increment the key by the specified value

func (*BuntDB) MDel

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

MDel - removes key(s) from the store

func (*BuntDB) MGet

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

MGet - fetch multiple values of the specified keys

func (*BuntDB) MSet

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

MSet - sets multiple key-value pairs

func (*BuntDB) Scan

func (bdb *BuntDB) Scan(opt ScannerOptions) error

Scan - iterate over the whole store using the handler function

func (*BuntDB) Set

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

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

func (*BuntDB) Size

func (bdb *BuntDB) Size() int64

Size - Not implemented

func (*BuntDB) TTL

func (bdb *BuntDB) 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
	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) 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 (*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) 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