ledisdb/store/goleveldb/snapshot.go

27 lines
449 B
Go
Raw Normal View History

2014-08-25 10:18:23 +04:00
package goleveldb
import (
2020-04-24 09:10:03 +03:00
"github.com/ledisdb/ledisdb/store/driver"
2014-11-20 17:52:29 +03:00
"github.com/syndtr/goleveldb/leveldb"
2014-08-25 10:18:23 +04:00
)
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()
}