Documentation ¶
Index ¶
- Constants
- func GetCreateTables() string
- type LevelDBStore
- func (self *LevelDBStore) BatchCommit() error
- func (self *LevelDBStore) BatchDelete(key []byte)
- func (self *LevelDBStore) BatchPut(key []byte, value []byte)
- func (self *LevelDBStore) Close() error
- func (self *LevelDBStore) Delete(key []byte) error
- func (self *LevelDBStore) Get(key []byte) ([]byte, error)
- func (self *LevelDBStore) Has(key []byte) (bool, error)
- func (self *LevelDBStore) NewBatch()
- func (self *LevelDBStore) Put(key []byte, value []byte) error
- func (self *LevelDBStore) QueryKeysByPrefix(prefix []byte) ([][]byte, error)
- func (self *LevelDBStore) QueryStringKeysByPrefix(prefix []byte) ([]string, error)
- type SQLiteStorage
- func (this *SQLiteStorage) Close() error
- func (this *SQLiteStorage) Exec(query string, args ...interface{}) (bool, error)
- func (this *SQLiteStorage) InsertTask(id, fileHash, fileName, walletAddr string, taskType uint64) (bool, error)
- func (this *SQLiteStorage) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (this *SQLiteStorage) UpdateTaskId(id, fileHash, fileName, walletAddr string, taskType uint64) (bool, error)
- type Store
- type Task
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) 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) 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)
Click to show internal directories.
Click to hide internal directories.