cdb

package
v0.0.0-...-03c5838 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright (C) 2018 go-cloudcard authors

This file is part of the go-cloudcard library.

the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-cloudcard library.

the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-cloudcard library.

the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-cloudcard library.

the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-cloudcard library.

the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	TypeLevelDB  = "levelDB"
	TypeBadgerDB = "badgerDB"
)

Variables

View Source
var (
	ErrBucketNotExist = errors.New("bucket does not exist")
	ErrKeyNotExist    = errors.New("key does not exist")
)
View Source
var (
	ErrKeyNotFound = errors.New("not found")
)

Functions

func NewcloudcardDB

func NewcloudcardDB(filename string) (*cloudcardDB, error)

func SetDbConfig

func SetDbConfig(conf *config.Config, dbConfig *DbConfig)

Types

type BadgerDB

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

func NewBadgerDB

func NewBadgerDB(dbcfg *DbConfig) (*BadgerDB, error)

func (*BadgerDB) Close

func (db *BadgerDB) Close() error

func (*BadgerDB) Delete

func (db *BadgerDB) Delete(key []byte) error

func (*BadgerDB) DisableBatch

func (db *BadgerDB) DisableBatch()

func (*BadgerDB) EnableBatch

func (db *BadgerDB) EnableBatch()

func (*BadgerDB) Flush

func (db *BadgerDB) Flush() error

func (*BadgerDB) Get

func (db *BadgerDB) Get(key []byte) ([]byte, error)

func (*BadgerDB) Has

func (db *BadgerDB) Has(key []byte) (bool, error)

func (*BadgerDB) Put

func (db *BadgerDB) Put(key, value []byte) error

func (*BadgerDB) ValueSize

func (db *BadgerDB) ValueSize() int

type Batcher

type Batcher interface {
	ValueSize() int
	// EnableBatch enable batch write.
	EnableBatch()
	// DisableBatch disable batch write.
	DisableBatch()
	Flush() error
}

type Compacter

type Compacter interface {
	Compact(start []byte, limit []byte) error
}

type DbConfig

type DbConfig struct {
	DbType      string `yaml:"db_type"`
	EnableBatch bool   `yaml:"enable_batch"`
	DbDir       string `yaml:"db_dir"`
}

func GetDbConfig

func GetDbConfig(config *config.Config) *DbConfig

func NewDefaultDbConfig

func NewDefaultDbConfig() *DbConfig

type Iteratee

type Iteratee interface {
	NewIterator() Iterator
	NewIteratorWithPrefix(prefix []byte) Iterator
}

type Iterator

type Iterator interface {
	Next() bool
	Error() error
	Key() []byte
	Value() []byte
	Release()
}

type LevelDB

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

func NewLevelDB

func NewLevelDB(dbcfg *DbConfig, cache int, handles int) (*LevelDB, error)

func (*LevelDB) Close

func (db *LevelDB) Close() error

func (*LevelDB) Compact

func (db *LevelDB) Compact(start []byte, limit []byte) error

func (*LevelDB) Delete

func (db *LevelDB) Delete(key []byte) error

func (*LevelDB) DisableBatch

func (db *LevelDB) DisableBatch()

func (*LevelDB) EnableBatch

func (db *LevelDB) EnableBatch()

func (*LevelDB) Flush

func (db *LevelDB) Flush() error

func (*LevelDB) Get

func (db *LevelDB) Get(key []byte) ([]byte, error)

func (*LevelDB) Has

func (db *LevelDB) Has(key []byte) (bool, error)

func (*LevelDB) NewIterator

func (db *LevelDB) NewIterator() Iterator

func (*LevelDB) NewIteratorWithPrefix

func (db *LevelDB) NewIteratorWithPrefix(prefix []byte) Iterator

func (*LevelDB) Put

func (db *LevelDB) Put(key, value []byte) error

func (*LevelDB) ValueSize

func (db *LevelDB) ValueSize() int

type MemoryBatch

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

MemoryBatch do batch task in memory storage

type MemoryDB

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

MemoryDB the nodes in trie.

func NewMemoryStorage

func NewMemoryStorage() (*MemoryDB, error)

NewMemoryStorage init a storage

func (*MemoryDB) Close

func (db *MemoryDB) Close() error

func (*MemoryDB) Del

func (db *MemoryDB) Del(key []byte) error

Del delete the key in Storage.

func (*MemoryDB) Delete

func (db *MemoryDB) Delete(key []byte) error

func (*MemoryDB) DisableBatch

func (db *MemoryDB) DisableBatch()

DisableBatch disable batch write.

func (*MemoryDB) EnableBatch

func (db *MemoryDB) EnableBatch()

EnableBatch enable batch write.

func (*MemoryDB) Flush

func (db *MemoryDB) Flush() error

Flush write and flush pending batch write.

func (*MemoryDB) Get

func (db *MemoryDB) Get(key []byte) ([]byte, error)

Get return value to the key in Storage

func (*MemoryDB) Has

func (db *MemoryDB) Has(key []byte) (bool, error)

func (*MemoryDB) Put

func (db *MemoryDB) Put(key []byte, value []byte) error

Put put the key-value entry to Storage

func (*MemoryDB) ValueSize

func (db *MemoryDB) ValueSize() int

type Reader

type Reader interface {
	Has(key []byte) (bool, error)
	Get(key []byte) ([]byte, error)
}

type Stater

type Stater interface {
	Stat(property string) (string, error)
}

type Storage

type Storage interface {
	Reader
	Writer
	Close() error
	Batcher
}

func NewDB

func NewDB(config *config.Config) (Storage, error)

type Writer

type Writer interface {
	Delete(key []byte) error
	Put(key, value []byte) error
}

Jump to

Keyboard shortcuts

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