-
Notifications
You must be signed in to change notification settings - Fork 3
/
kv.go
37 lines (30 loc) · 874 Bytes
/
kv.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package disk
import "time"
// DB Interface
type DB interface {
Incr(k string, by int64) (int64, error)
Set(k string, v []byte, ttl time.Duration) error
MSet(data map[string][]byte) error
Get(k string) ([]byte, error)
MGet(keys []string) [][]byte
TTL(key string) int64
MDel(keys []string) error
Del(key string) error
Scan(ScannerOpt ScannerOptions) error
Size() int64
GC() error
Close()
}
// ScannerOptions - represents the options for a scanner
type ScannerOptions struct {
// from where to start
Offset string
// whether to include the value of the offset in the result or not
IncludeOffset bool
// the prefix that must be exists in each key in the iteration
Prefix string
// fetch the values (true) or this is a key only iteration (false)
FetchValues bool
// the handler that handles the incoming data
Handler func(k []byte, v []byte) error
}