storage

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright (C) 2018 go-dappley authors

This file is part of the go-dappley library.

the go-dappley 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-dappley 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-dappley library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-dappley library.

the go-dappley 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-dappley 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-dappley library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyInvalid = errors.New("Key is invalid")
)
View Source
var (
	ErrLevelDbNotAbleToOpenFile = errors.New("leveldb fails to open file")
)

Functions

func DbExists

func DbExists(dbFilePath string) bool

Types

type FileLoader added in v0.1.2

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

func NewFileLoader added in v0.1.2

func NewFileLoader(filePath string) *FileLoader

func (*FileLoader) ReadFromFile added in v0.1.2

func (fl *FileLoader) ReadFromFile() ([]byte, error)

func (*FileLoader) SaveToFile added in v0.1.2

func (fl *FileLoader) SaveToFile(buffer bytes.Buffer)

type FileStorage added in v0.1.2

type FileStorage interface {
	ReadFromFile() ([]byte, error)
	SaveToFile(buffer bytes.Buffer)
}

type LevelDB

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

func OpenDatabase

func OpenDatabase(dbFilePath string) *LevelDB

Create a new database instance

func (*LevelDB) Close

func (ldb *LevelDB) Close() error

func (*LevelDB) Del added in v0.1.2

func (ldb *LevelDB) Del(key []byte) error

func (*LevelDB) DisableBatch added in v0.1.2

func (ldb *LevelDB) DisableBatch()

func (*LevelDB) EnableBatch added in v0.1.2

func (ldb *LevelDB) EnableBatch()

func (*LevelDB) Flush added in v0.1.2

func (ldb *LevelDB) Flush() error

func (*LevelDB) Get

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

func (*LevelDB) Put

func (ldb *LevelDB) Put(key []byte, val []byte) error

type RamStorage

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

func NewRamStorage

func NewRamStorage() *RamStorage

func (*RamStorage) Close

func (rs *RamStorage) Close() error

func (*RamStorage) Del added in v0.1.2

func (rs *RamStorage) Del(key []byte) error

func (*RamStorage) DisableBatch added in v0.1.2

func (rs *RamStorage) DisableBatch()

DisableBatch disable batch write.

func (*RamStorage) EnableBatch added in v0.1.2

func (rs *RamStorage) EnableBatch()

EnableBatch enable batch write.

func (*RamStorage) Flush added in v0.1.2

func (rs *RamStorage) Flush() error

Flush write and flush pending batch write.

func (*RamStorage) Get

func (rs *RamStorage) Get(key []byte) ([]byte, error)

func (*RamStorage) Put

func (rs *RamStorage) Put(key []byte, val []byte) error

type Storage

type Storage interface {
	Close() error

	Get(key []byte) ([]byte, error)

	Put(key []byte, val []byte) error

	Del(key []byte) error

	// EnableBatch enable batch write.
	EnableBatch()

	// DisableBatch disable batch write.
	DisableBatch()

	// Flush write and flush pending batch write.
	Flush() error
}

Directories

Path Synopsis
Package storage_mock is a generated GoMock package.
Package storage_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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