Documentation ¶
Index ¶
- Constants
- func Register(name string, fn func(path string) (Store, error))
- type Badger
- func (s *Badger) BatchClose() error
- func (s *Badger) BatchDelete(k []byte) error
- func (s *Badger) BatchSet(k, v []byte) error
- func (s *Badger) Close() error
- func (s *Badger) Delete(k []byte, sync ...bool) 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) NewBatch() error
- func (s *Badger) Set(k, v []byte, sync ...bool) error
- func (s *Badger) WALName() string
- func (s *Badger) Write(sync ...bool) error
- type Batch
- type Bolt
- func (s *Bolt) BatchClose() error
- func (s *Bolt) BatchDelete(k []byte) error
- func (s *Bolt) BatchSet(k, v []byte) error
- func (s *Bolt) Close() error
- func (s *Bolt) Delete(k []byte, sync ...bool) error
- func (s *Bolt) ForEach(fn func(k, v []byte) error) error
- func (s *Bolt) Get(k []byte) (b []byte, err error)
- func (s *Bolt) Has(k []byte) (bool, error)
- func (s *Bolt) NewBatch() error
- func (s *Bolt) Set(k []byte, v []byte, sync ...bool) error
- func (s *Bolt) WALName() string
- func (s *Bolt) Write(sync ...bool) error
- type Leveldb
- func (s *Leveldb) BatchClose() error
- func (s *Leveldb) BatchDelete(k []byte) error
- func (s *Leveldb) BatchSet(k, v []byte) error
- func (s *Leveldb) Close() error
- func (s *Leveldb) Delete(k []byte, sync ...bool) 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) NewBatch() error
- func (s *Leveldb) Set(k, v []byte, sync ...bool) error
- func (s *Leveldb) WALName() string
- func (s *Leveldb) Write(sync ...bool) error
- type Store
Constants ¶
const (
// DefaultStore define default store engine
DefaultStore = "badger"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Badger ¶
type Badger struct {
// contains filtered or unexported fields
}
Badger badger.KV db store
func (*Badger) BatchDelete ¶
BatchDelete deletes a key with batch
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.
Use `snyc = true` set the db snyc mode
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 ¶
Bolt bolt store struct
func (*Bolt) BatchDelete ¶
BatchDelete delete a key in the batch
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.
type Leveldb ¶
type Leveldb struct {
// contains filtered or unexported fields
}
Leveldb leveldb store struct
func (*Leveldb) BatchDelete ¶
BatchDelete delete a key in the batch
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.
func (*Leveldb) Get ¶
Get gets the value for the given key. It returns ErrNotFound if the DB does not contains the key.
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.
func (*Leveldb) Set ¶
Set sets the provided value for a given key. If key is not present, it is created.
type Store ¶
type Store interface { Set(k, v []byte, sync ...bool) error Get(k []byte) ([]byte, error) Delete(k []byte, sync ...bool) error Has(k []byte) (bool, error) ForEach(fn func(k, v []byte) error) error Close() error WALName() string // NewBatch() error BatchSet(k, v []byte) error // BatchGet(k []byte) ([]byte, error) BatchDelete(k []byte) error Write(snyc ...bool) error BatchClose() error }
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.