Documentation ¶
Index ¶
- Constants
- func RegisterStore(name string, fn func(path string) (Store, error))
- type Badger
- func (s *Badger) Close() error
- func (s *Badger) Delete(k []byte) error
- func (s *Badger) ForEach(fn func(k, v []byte) error) error
- func (s *Badger) Get(k []byte) ([]byte, error)
- func (s *Badger) Has(k []byte) (bool, error)
- func (s *Badger) Len() (int64, int64)
- func (s *Badger) Set(k, v []byte) error
- func (s *Badger) WALName() string
- type Bolt
- type Leveldb
- func (s *Leveldb) Close() error
- func (s *Leveldb) Delete(k []byte) error
- func (s *Leveldb) ForEach(fn func(k, v []byte) error) error
- func (s *Leveldb) Get(k []byte) ([]byte, error)
- func (s *Leveldb) Has(k []byte) (bool, error)
- func (s *Leveldb) Len() (leveldb.Sizes, error)
- func (s *Leveldb) Set(k, v []byte) error
- func (s *Leveldb) WALName() string
- type Store
Constants ¶
const (
// DefaultStore default store engine
DefaultStore = "ldb"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Badger ¶
type Badger struct {
// contains filtered or unexported fields
}
Badger badger.KV db store
func (*Badger) Close ¶
Close closes a KV. It's crucial to call it to ensure all the pending updates make their way to disk.
func (*Badger) Delete ¶
Delete deletes a key. Exposing this so that user does not have to specify the Entry directly. For example, BitDelete seems internal to badger.
func (*Badger) Len ¶
Len returns the size of lsm and value log files in bytes. It can be used to decide how often to call RunValueLogGC.
type Bolt ¶
type Bolt struct {
// contains filtered or unexported fields
}
Bolt bolt store struct
func (*Bolt) Close ¶
Close releases all database resources. All transactions must be closed before closing the database.
func (*Bolt) Delete ¶
Delete deletes a key. Exposing this so that user does not have to specify the Entry directly.
func (*Bolt) Get ¶
Get executes a function within the context of a managed read-only transaction. Any error that is returned from the function is returned from the View() method.
func (*Bolt) Set ¶
Set executes a function within the context of a read-write managed transaction. If no error is returned from the function then the transaction is committed. If an error is returned then the entire transaction is rolled back. Any error that is returned from the function or returned from the commit is returned from the Update() method.
type Leveldb ¶
type Leveldb struct {
// contains filtered or unexported fields
}
Leveldb leveldb store
func (*Leveldb) Close ¶
Close closes the DB. This will also releases any outstanding snapshot, abort any in-flight compaction and discard open transaction.
func (*Leveldb) Delete ¶
Delete deletes the value for the given key. Delete will not returns error if key doesn't exist. Write merge also applies for Delete, see Write.
It is safe to modify the contents of the arguments after Delete returns but not before.
func (*Leveldb) Get ¶
Get gets the value for the given key. It returns ErrNotFound if the DB does not contains the key.
The returned slice is its own copy, it is safe to modify the contents of the returned slice. It is safe to modify the contents of the argument after Get returns.
func (*Leveldb) Has ¶
Has returns true if the DB does contains the given key. It is safe to modify the contents of the argument after Has returns.
func (*Leveldb) Len ¶
Len calculates approximate sizes of the given key ranges. The length of the returned sizes are equal with the length of the given ranges. The returned sizes measure store space usage, so if the user data compresses by a factor of ten, the returned sizes will be one-tenth the size of the corresponding user data size. The results may not include the sizes of recently written data.
type Store ¶
type Store interface { // type KVBatch interface { Set(k, v []byte) error Get(k []byte) ([]byte, error) Delete(k []byte) error Has(k []byte) (bool, error) ForEach(fn func(k, v []byte) error) error Close() error WALName() string }
Store is store interface
func OpenLeveldb ¶
OpenLeveldb opens or creates a DB for the given store. The DB will be created if not exist, unless ErrorIfMissing is true. Also, if ErrorIfExist is true and the DB exist Open will returns os.ErrExist error.