Documentation ¶
Index ¶
- Variables
- type Database
- type Deleter
- type LDBDatabase
- func (db *LDBDatabase) BeginTx() bool
- func (db *LDBDatabase) Close()
- func (db *LDBDatabase) CommitTx() error
- func (db *LDBDatabase) Delete(key []byte) error
- func (db *LDBDatabase) Get(key []byte) ([]byte, error)
- func (db *LDBDatabase) Has(key []byte) (bool, error)
- func (db *LDBDatabase) LDB() *leveldb.DB
- func (db *LDBDatabase) Path() string
- func (db *LDBDatabase) Put(key []byte, value []byte) error
- func (db *LDBDatabase) RollbackTx() error
- type MemDatabase
- type Putter
Constants ¶
This section is empty.
Variables ¶
var OpenFileLimit = 64
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { Putter Deleter Get(key []byte) ([]byte, error) Has(key []byte) (bool, error) Close() // BeginTx starts a db tx, there can be only one tx per connection. // After a tx begins, all later operation will be managed by the tx. // // Returns false if old tx being used. // // not thread-safe. BeginTx() bool RollbackTx() error CommitTx() error }
Database wraps all database operations. All methods are safe for concurrent use.
type Deleter ¶
Deleter wraps the database delete operation supported by both batches and regular databases.
type LDBDatabase ¶
type LDBDatabase struct {
// contains filtered or unexported fields
}
func NewLDBDatabase ¶
func NewLDBDatabase(file string, cache int, handles int) (*LDBDatabase, error)
NewLDBDatabase returns a LevelDB wrapped object.
func (*LDBDatabase) BeginTx ¶
func (db *LDBDatabase) BeginTx() bool
BeginTx starts a db tx, there can be only one tx per connection. After a tx begins, all later operation will be managed by the tx.
Returns whether a new tx created, "false" if old tx being used.
not thread-safe.
func (*LDBDatabase) Close ¶
func (db *LDBDatabase) Close()
func (*LDBDatabase) CommitTx ¶
func (db *LDBDatabase) CommitTx() error
CommitTx commits all the changes in the db transaction. Caller should rollback the transactio nmanually by calling`RollbackTx`, if any error retuns
func (*LDBDatabase) Delete ¶
func (db *LDBDatabase) Delete(key []byte) error
Delete deletes the key from the queue and database
func (*LDBDatabase) Get ¶
func (db *LDBDatabase) Get(key []byte) ([]byte, error)
Get returns the given key if it's present.
func (*LDBDatabase) LDB ¶
func (db *LDBDatabase) LDB() *leveldb.DB
func (*LDBDatabase) Path ¶
func (db *LDBDatabase) Path() string
Path returns the path to the database directory.
func (*LDBDatabase) Put ¶
func (db *LDBDatabase) Put(key []byte, value []byte) error
Put puts the given key / value to the queue
func (*LDBDatabase) RollbackTx ¶
func (db *LDBDatabase) RollbackTx() error
RollbackTx abandon all the changes made in the transaction
type MemDatabase ¶
type MemDatabase struct {
// contains filtered or unexported fields
}
* This is a test memory database. Do not use for any production it does not get persisted
func NewMemDatabase ¶
func NewMemDatabase() *MemDatabase
func NewMemDatabaseWithCap ¶
func NewMemDatabaseWithCap(size int) *MemDatabase
func (*MemDatabase) Close ¶
func (db *MemDatabase) Close()
func (*MemDatabase) Delete ¶
func (db *MemDatabase) Delete(key []byte) error
func (*MemDatabase) Keys ¶
func (db *MemDatabase) Keys() [][]byte