Documentation ¶
Index ¶
- type LevelHub
- func (hub *LevelHub) Clean()
- func (hub *LevelHub) Close(nums ...int)
- func (hub *LevelHub) Delete(num int, key []byte, wo *opt.WriteOptions) error
- func (hub *LevelHub) Force()
- func (hub *LevelHub) Get(num int, key []byte, ro *opt.ReadOptions) (value []byte, err error)
- func (hub *LevelHub) Has(num int, key []byte, ro *opt.ReadOptions) (ret bool, err error)
- func (hub *LevelHub) IsOpen(num int) bool
- func (hub *LevelHub) NewIterator(num int, slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
- func (hub *LevelHub) Put(num int, key, value []byte, wo *opt.WriteOptions) error
- type Options
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LevelHub ¶
type LevelHub struct {
// contains filtered or unexported fields
}
LevelHub leveldb hub
func NewLevelHub ¶
NewLevelHub create LevelHub
Example ¶
hub := NewLevelHub("tmp", nil) defer hub.Close() hub.Put(1, []byte("key"), []byte("A"), nil) hub.Put(2, []byte("key"), []byte("B"), nil) a, _ := hub.Get(1, []byte("key"), nil) fmt.Println(string(a)) b, _ := hub.Get(2, []byte("key"), nil) fmt.Println(string(b))
Output: A B
func (*LevelHub) NewIterator ¶
NewIterator returns an iterator for the latest snapshot of the underlying DB.
type Options ¶
Options hub options
Example ¶
hub := NewLevelHub("tmp", &Options{ Expire: time.Second * 3, Min: 1, // More than Min settings will trigger the expiration }) defer hub.Close() hub.Put(1, []byte("key"), []byte("val"), nil) hub.Put(2, []byte("key"), []byte("val"), nil) fmt.Println(hub.IsOpen(1), hub.IsOpen(2)) time.Sleep(time.Second * 10) fmt.Println(hub.IsOpen(1), hub.IsOpen(2))
Output: true true false false
Click to show internal directories.
Click to hide internal directories.