store

package
v0.0.0-...-69e5406 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BITSPERKEY = 10

used to compute the size of bloom filter bits array . too small will lead to high false positive rate.

View Source
const CreateTasks string = "CREATE TABLE IF NOT EXISTS " + DSP_TASK_TABLE_NAME +
	" (id VARCHAR[255] NOT NULL PRIMARY KEY, fileHash VARCHAR[255] NOT NULL, fileName VARCHAR[255] NOT NULL, walletAddr VARCHAR[255] NOT NULL, type INTEGER NOT NULL, createdAt DATE, updatedAt DATE);"
View Source
const DBVersion int = 6
View Source
const DSP_TASK_TABLE_NAME = "dsp_tasks"
View Source
const ScriptCreateTables string = `PRAGMA foreign_keys=off;
BEGIN TRANSACTION;
%s
COMMIT;
PRAGMA foreign_keys=on;
`

Variables

This section is empty.

Functions

func GetCreateTables

func GetCreateTables() string

Types

type LevelDBStore

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

func NewLevelDBStore

func NewLevelDBStore(file string) (*LevelDBStore, error)

NewLevelDBStore return LevelDBStore instance

func (*LevelDBStore) BatchCommit

func (self *LevelDBStore) BatchCommit() error

BatchCommit commit batch to leveldb

func (*LevelDBStore) BatchDelete

func (self *LevelDBStore) BatchDelete(key []byte)

BatchDelete delete a key to leveldb batch

func (*LevelDBStore) BatchPut

func (self *LevelDBStore) BatchPut(key []byte, value []byte)

BatchPut put a key-value pair to leveldb batch

func (*LevelDBStore) Close

func (self *LevelDBStore) Close() error

Close close leveldb

func (*LevelDBStore) Delete

func (self *LevelDBStore) Delete(key []byte) error

Delete the the in leveldb

func (*LevelDBStore) Get

func (self *LevelDBStore) Get(key []byte) ([]byte, error)

Get the value of a key from leveldb

func (*LevelDBStore) Has

func (self *LevelDBStore) Has(key []byte) (bool, error)

Has return whether the key is exist in leveldb

func (*LevelDBStore) NewBatch

func (self *LevelDBStore) NewBatch()

NewBatch start commit batch

func (*LevelDBStore) Put

func (self *LevelDBStore) Put(key []byte, value []byte) error

Put a key-value pair to leveldb

func (*LevelDBStore) QueryKeysByPrefix

func (self *LevelDBStore) QueryKeysByPrefix(prefix []byte) ([][]byte, error)

QueryKeysByPrefix. find all keys by prefix

func (*LevelDBStore) QueryStringKeysByPrefix

func (self *LevelDBStore) QueryStringKeysByPrefix(prefix []byte) ([]string, error)

QueryStringKeysByPrefix. find all keys by prefix

type SQLiteStorage

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

func NewSQLiteStorage

func NewSQLiteStorage(databasePath, createTableScript string) (*SQLiteStorage, error)

func (*SQLiteStorage) Close

func (this *SQLiteStorage) Close() error

func (*SQLiteStorage) Exec

func (this *SQLiteStorage) Exec(query string, args ...interface{}) (bool, error)

func (*SQLiteStorage) InsertTask

func (this *SQLiteStorage) InsertTask(id, fileHash, fileName, walletAddr string, taskType uint64) (bool, error)

func (*SQLiteStorage) Query

func (this *SQLiteStorage) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*SQLiteStorage) UpdateTaskId

func (this *SQLiteStorage) UpdateTaskId(id, fileHash, fileName, walletAddr string, taskType uint64) (bool, error)

type Store

type Store interface {
	Put(key string, value interface{}) error
	Get(key string) (interface{}, error)
	Delete(key string) error
}

type Task

type Task struct {
	Id         string
	FileHash   string
	FileName   string
	WalletAddr string
	Type       uint64
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

Jump to

Keyboard shortcuts

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