persist

package
v0.0.0-...-53e3d08 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDB

type BoltDB struct {
	*bolt.DB
	// contains filtered or unexported fields
}

BoltDB use boltdb to persist data

func NewBoltDB

func NewBoltDB(path string) (*BoltDB, error)

NewBoltDB creates a bolt database

func (*BoltDB) BatchFetch

func (p *BoltDB) BatchFetch(offset []byte, size int) ([]*KV, error)

BatchFetch fetches KVs by offset in batch mode

func (*BoltDB) BatchPut

func (p *BoltDB) BatchPut(kvs []*KV) error

BatchPut puts KVs in batch mode

func (*BoltDB) BatchPutV

func (p *BoltDB) BatchPutV(vs [][]byte) error

BatchPutV puts values in batch mode

func (*BoltDB) BucketDelete

func (p *BoltDB) BucketDelete(bucket, key []byte) error

BucketDelete deletes a KV in bucket by key

func (*BoltDB) BucketGet

func (p *BoltDB) BucketGet(bucket, key []byte) (value []byte, err error)

BucketGet gets a KV from bucket by key

func (*BoltDB) BucketList

func (p *BoltDB) BucketList(bucket []byte) (map[string][]byte, error)

BucketList lists all KVs in bucket

func (*BoltDB) BucketPut

func (p *BoltDB) BucketPut(bucket, key, value []byte) error

BucketPut puts a KV into bucket

func (*BoltDB) Clean

func (p *BoltDB) Clean(timestamp uint64) (count uint64, err error)

Clean cleans all KVs before timestamp

func (*BoltDB) Close

func (p *BoltDB) Close()

Close closes database

func (*BoltDB) Delete

func (p *BoltDB) Delete(key []byte) error

Delete deletes a KV

func (*BoltDB) Fetch

func (p *BoltDB) Fetch(offset []byte) (key, value []byte, err error)

Fetch fetches a KV by offset

func (*BoltDB) Get

func (p *BoltDB) Get(key []byte) (value []byte, err error)

Get gets a KV by key

func (*BoltDB) Put

func (p *BoltDB) Put(key, value []byte) error

Put puts a KV

func (*BoltDB) Sequence

func (p *BoltDB) Sequence() (sid uint64, err error)

Sequence returns the sequence id

type Database

type Database interface {
	Sequence() (uint64, error)
	// Put(key, value []byte) error
	Get(key []byte) ([]byte, error)
	// Fetch(offset []byte) ([]byte, []byte, error)
	Delete(key []byte) error
	Clean(timestamp uint64) (uint64, error)
	Close()

	BatchPut(kvs []*KV) error
	BatchPutV(vs [][]byte) error
	BatchFetch(offset []byte, size int) ([]*KV, error)

	BucketPut(bucket, key, value []byte) error
	BucketGet(bucket, key []byte) ([]byte, error)
	BucketList(bucket []byte) (map[string][]byte, error)
	BucketDelete(bucket, key []byte) error
}

Database persistence interfaces

type Factory

type Factory struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Factory persistence factory

func NewFactory

func NewFactory(dir string) (*Factory, error)

NewFactory creates a persistence factory

func (*Factory) Close

func (f *Factory) Close()

Close close factory to release all databases

func (*Factory) NewDB

func (f *Factory) NewDB(name string) (Database, error)

NewDB creates a persistence database

type KV

type KV struct {
	Key   []byte
	Value []byte
}

KV key-value pair

Jump to

Keyboard shortcuts

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