disk

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 13 Imported by: 1

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 added in v0.0.2

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

BBoltDB - represents a bbolt db implementation

func OpenBoltDBB added in v0.0.2

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

OpenBoltDB - Opens the specified path

func (*BBoltDB) Close added in v0.0.2

func (b *BBoltDB) Close()

Close ...

func (*BBoltDB) Del added in v0.0.2

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

Del - removes key from the store

func (*BBoltDB) GC added in v0.0.2

func (b *BBoltDB) GC() error

GC - runs the garbage collector

func (*BBoltDB) Get added in v0.0.2

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

Get - fetches the value of the specified k

func (*BBoltDB) Incr added in v0.0.2

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

Incr - increment the key by the specified value

func (*BBoltDB) MDel added in v0.0.2

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

MDel - removes key(s) from the store

func (*BBoltDB) MGet added in v0.0.2

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

MGet - fetch multiple values of the specified keys

func (*BBoltDB) MSet added in v0.0.2

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

MSet - sets multiple key-value pairs

func (*BBoltDB) Scan added in v0.0.2

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

Scan - iterate over the whole store using the handler function

func (*BBoltDB) Set added in v0.0.2

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 added in v0.0.2

func (b *BBoltDB) Size() int64

Size - returns the size of the database in bytes

func (*BBoltDB) TTL added in v0.0.2

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

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

type BuntDB added in v0.0.3

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

BuntDB - represents a BuntDB implementation

func OpenBuntDB added in v0.0.3

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

OpenBuntDB - Opens the specified path

func (*BuntDB) Close added in v0.0.3

func (bdb *BuntDB) Close()

Close

func (*BuntDB) Del added in v0.0.3

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

Del - removes key from the store

func (*BuntDB) GC added in v0.0.3

func (bdb *BuntDB) GC() error

GC - runs the garbage collector

func (*BuntDB) Get added in v0.0.3

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

Get - fetches the value of the specified k

func (*BuntDB) Incr added in v0.0.3

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

Incr - increment the key by the specified value

func (*BuntDB) MDel added in v0.0.3

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

MDel - removes key(s) from the store

func (*BuntDB) MGet added in v0.0.3

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

MGet - fetch multiple values of the specified keys

func (*BuntDB) MSet added in v0.0.3

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

MSet - sets multiple key-value pairs

func (*BuntDB) Scan added in v0.0.3

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

Scan - iterate over the whole store using the handler function

func (*BuntDB) Set added in v0.0.3

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 added in v0.0.3

func (bdb *BuntDB) Size() int64

Size - Not implemented

func (*BuntDB) TTL added in v0.0.3

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 added in v0.0.2

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

PogrebDB - represents a pogreb db implementation

func (*PogrebDB) Close added in v0.0.2

func (pdb *PogrebDB) Close()

Close ...

func (*PogrebDB) Del added in v0.0.2

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

Del - removes key from the store

func (*PogrebDB) GC added in v0.0.2

func (pdb *PogrebDB) GC() error

GC - runs the garbage collector

func (*PogrebDB) Get added in v0.0.2

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

Get - fetches the value of the specified k

func (*PogrebDB) Incr added in v0.0.2

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

Incr - increment the key by the specified value

func (*PogrebDB) MDel added in v0.0.2

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

MDel - removes key(s) from the store

func (*PogrebDB) MGet added in v0.0.2

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

MGet - fetch multiple values of the specified keys

func (*PogrebDB) MSet added in v0.0.2

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

MSet - sets multiple key-value pairs

func (*PogrebDB) Scan added in v0.0.2

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

Scan - iterate over the whole store using the handler function

func (*PogrebDB) Set added in v0.0.2

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 added in v0.0.2

func (pdb *PogrebDB) Size() int64

Size - returns the size of the database in bytes

func (*PogrebDB) TTL added in v0.0.2

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