Documentation ¶
Index ¶
- func Options() opt.Options
- type LevelDB
- func (db *LevelDB) Begin() (database.Transaction, error)
- func (db *LevelDB) Close() error
- func (db *LevelDB) Compact() error
- func (db *LevelDB) Cursor(bucket *database.Bucket) (database.Cursor, error)
- func (db *LevelDB) Delete(key *database.Key) error
- func (db *LevelDB) Get(key *database.Key) ([]byte, error)
- func (db *LevelDB) Has(key *database.Key) (bool, error)
- func (db *LevelDB) Put(key *database.Key, value []byte) error
- type LevelDBCursor
- func (c *LevelDBCursor) Close() error
- func (c *LevelDBCursor) First() bool
- func (c *LevelDBCursor) Key() (*database.Key, error)
- func (c *LevelDBCursor) Last() bool
- func (c *LevelDBCursor) Next() bool
- func (c *LevelDBCursor) Seek(key *database.Key) error
- func (c *LevelDBCursor) Value() ([]byte, error)
- type LevelDBTransaction
- func (tx *LevelDBTransaction) Commit() error
- func (tx *LevelDBTransaction) Cursor(bucket *database.Bucket) (database.Cursor, error)
- func (tx *LevelDBTransaction) Delete(key *database.Key) error
- func (tx *LevelDBTransaction) Get(key *database.Key) ([]byte, error)
- func (tx *LevelDBTransaction) Has(key *database.Key) (bool, error)
- func (tx *LevelDBTransaction) Put(key *database.Key, value []byte) error
- func (tx *LevelDBTransaction) Rollback() error
- func (tx *LevelDBTransaction) RollbackUnlessClosed() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LevelDB ¶
type LevelDB struct {
// contains filtered or unexported fields
}
LevelDB defines a thin wrapper around leveldb.
func NewLevelDB ¶
NewLevelDB opens a leveldb instance defined by the given path.
func (*LevelDB) Begin ¶
func (db *LevelDB) Begin() (database.Transaction, error)
Begin begins a new transaction.
func (*LevelDB) Delete ¶
Delete deletes the value for the given key. Will not return an error if the key doesn't exist.
func (*LevelDB) Get ¶
Get gets the value for the given key. It returns ErrNotFound if the given key does not exist.
type LevelDBCursor ¶
type LevelDBCursor struct {
// contains filtered or unexported fields
}
LevelDBCursor is a thin wrapper around native leveldb iterators.
func (*LevelDBCursor) Close ¶
func (c *LevelDBCursor) Close() error
Close releases associated resources.
func (*LevelDBCursor) First ¶
func (c *LevelDBCursor) First() bool
First moves the iterator to the first key/value pair. It returns false if such a pair does not exist. Panics if the cursor is closed.
func (*LevelDBCursor) Key ¶
func (c *LevelDBCursor) Key() (*database.Key, error)
Key returns the key of the current key/value pair, or ErrNotFound if done. Note that the key is trimmed to not include the prefix the cursor was opened with. The caller should not modify the contents of the returned slice, and its contents may change on the next call to Next.
func (*LevelDBCursor) Last ¶
func (c *LevelDBCursor) Last() bool
func (*LevelDBCursor) Next ¶
func (c *LevelDBCursor) Next() bool
Next moves the iterator to the next key/value pair. It returns whether the iterator is exhausted. Panics if the cursor is closed.
func (*LevelDBCursor) Seek ¶
func (c *LevelDBCursor) Seek(key *database.Key) error
Seek moves the iterator to the first key/value pair whose key is greater than or equal to the given key. It returns ErrNotFound if such pair does not exist.
func (*LevelDBCursor) Value ¶
func (c *LevelDBCursor) Value() ([]byte, error)
Value returns the value of the current key/value pair, or ErrNotFound if done. The caller should not modify the contents of the returned slice, and its contents may change on the next call to Next.
type LevelDBTransaction ¶
type LevelDBTransaction struct {
// contains filtered or unexported fields
}
LevelDBTransaction is a thin wrapper around native leveldb batches. It supports both get and put.
Note that reads are done from the Database directly, so if another transaction changed the data, you will read the new data, and not the one from the time the transaction was opened/
Note: As it's currently implemented, if one puts data into the transaction then it will not be available to get within the same transaction.
func (*LevelDBTransaction) Commit ¶
func (tx *LevelDBTransaction) Commit() error
Commit commits whatever changes were made to the database within this transaction.
func (*LevelDBTransaction) Delete ¶
func (tx *LevelDBTransaction) Delete(key *database.Key) error
Delete deletes the value for the given key. Will not return an error if the key doesn't exist.
func (*LevelDBTransaction) Get ¶
func (tx *LevelDBTransaction) Get(key *database.Key) ([]byte, error)
Get gets the value for the given key. It returns ErrNotFound if the given key does not exist.
func (*LevelDBTransaction) Has ¶
func (tx *LevelDBTransaction) Has(key *database.Key) (bool, error)
Has returns true if the database does contains the given key.
func (*LevelDBTransaction) Put ¶
func (tx *LevelDBTransaction) Put(key *database.Key, value []byte) error
Put sets the value for the given key. It overwrites any previous value for that key.
func (*LevelDBTransaction) Rollback ¶
func (tx *LevelDBTransaction) Rollback() error
Rollback rolls back whatever changes were made to the database within this transaction.
func (*LevelDBTransaction) RollbackUnlessClosed ¶
func (tx *LevelDBTransaction) RollbackUnlessClosed() error
RollbackUnlessClosed rolls back changes that were made to the database within the transaction, unless the transaction had already been closed using either Rollback or Commit.