aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/lunny/nodb/store/db.go
diff options
context:
space:
mode:
authortechknowlogick <matti@mdranta.net>2019-02-05 11:52:51 -0500
committerGitHub <noreply@github.com>2019-02-05 11:52:51 -0500
commit9de871a0f8911030f8e06a881803cf722b8798ea (patch)
tree206400f0a5873d7d078fcdd004956036f07a1db5 /vendor/github.com/lunny/nodb/store/db.go
parentbf4badad1d68c18d7ffb92c69e09e4e8aa252935 (diff)
downloadgitea-9de871a0f8911030f8e06a881803cf722b8798ea.tar.gz
gitea-9de871a0f8911030f8e06a881803cf722b8798ea.zip
add other session providers (#5963)
Diffstat (limited to 'vendor/github.com/lunny/nodb/store/db.go')
-rw-r--r--vendor/github.com/lunny/nodb/store/db.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/vendor/github.com/lunny/nodb/store/db.go b/vendor/github.com/lunny/nodb/store/db.go
new file mode 100644
index 0000000000..00a8831a67
--- /dev/null
+++ b/vendor/github.com/lunny/nodb/store/db.go
@@ -0,0 +1,61 @@
+package store
+
+import (
+ "github.com/lunny/nodb/store/driver"
+)
+
+type DB struct {
+ driver.IDB
+}
+
+func (db *DB) NewIterator() *Iterator {
+ it := new(Iterator)
+ it.it = db.IDB.NewIterator()
+
+ return it
+}
+
+func (db *DB) NewWriteBatch() WriteBatch {
+ return db.IDB.NewWriteBatch()
+}
+
+func (db *DB) NewSnapshot() (*Snapshot, error) {
+ var err error
+ s := &Snapshot{}
+ if s.ISnapshot, err = db.IDB.NewSnapshot(); err != nil {
+ return nil, err
+ }
+
+ return s, nil
+}
+
+func (db *DB) RangeIterator(min []byte, max []byte, rangeType uint8) *RangeLimitIterator {
+ return NewRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{0, -1})
+}
+
+func (db *DB) RevRangeIterator(min []byte, max []byte, rangeType uint8) *RangeLimitIterator {
+ return NewRevRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{0, -1})
+}
+
+//count < 0, unlimit.
+//
+//offset must >= 0, if < 0, will get nothing.
+func (db *DB) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator {
+ return NewRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count})
+}
+
+//count < 0, unlimit.
+//
+//offset must >= 0, if < 0, will get nothing.
+func (db *DB) RevRangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator {
+ return NewRevRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count})
+}
+
+func (db *DB) Begin() (*Tx, error) {
+ tx, err := db.IDB.Begin()
+ if err != nil {
+ return nil, err
+ }
+
+ return &Tx{tx}, nil
+}