2019-02-05 16:52:51 +00:00
|
|
|
package goleveldb
|
|
|
|
|
|
|
|
import (
|
2020-11-03 06:04:09 +00:00
|
|
|
"gitea.com/lunny/nodb/store/driver"
|
2019-02-05 16:52:51 +00:00
|
|
|
"github.com/syndtr/goleveldb/leveldb"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Snapshot struct {
|
|
|
|
db *DB
|
|
|
|
snp *leveldb.Snapshot
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Snapshot) Get(key []byte) ([]byte, error) {
|
|
|
|
return s.snp.Get(key, s.db.iteratorOpts)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Snapshot) NewIterator() driver.IIterator {
|
|
|
|
it := &Iterator{
|
|
|
|
s.snp.NewIterator(nil, s.db.iteratorOpts),
|
|
|
|
}
|
|
|
|
return it
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Snapshot) Close() {
|
|
|
|
s.snp.Release()
|
|
|
|
}
|