-
Notifications
You must be signed in to change notification settings - Fork 0
/
ldb.go
77 lines (57 loc) · 1.27 KB
/
ldb.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package ldb
// @author Mikhail Kirillov <mikkirillov@yandex.ru>
// @version 1.011
// @date 2019-11-11
var store Storage = nil
var proxyConfig *Config
func Init(cfg *Config) {
if store == nil {
New(cfg, true)
}
}
func TestInit() {
Open("test=true")
}
func Close() {
if store != nil {
store.Close()
}
store = nil
}
func InitProxy(cfg *Config) {
proxyConfig = cfg
}
func Use(base string) {
cfg := &Config{
Path: proxyConfig.Path + "/" + base,
FileSize: proxyConfig.FileSize,
Compression: proxyConfig.Compression,
ReadOnly: proxyConfig.ReadOnly,
}
Close()
Init(cfg)
}
func Set(key []byte, value []byte) {
store.Set(key, value)
}
func Get(key []byte) []byte {
return store.Get(key)
}
func Has(key []byte) bool {
return store.Has(key)
}
func Del(key []byte) {
store.Del(key)
}
func Total(prefix []byte) int64 {
return store.Total(prefix)
}
func List(prefix []byte, limit int, offset int, RemovePrefix bool) [][]byte {
return store.List(prefix, limit, offset, RemovePrefix)
}
func ForEach(prefix []byte, RemovePrefix bool, fn FOR_EACH_FUNC) {
store.ForEach(prefix, RemovePrefix, fn)
}
func ForEachKey(prefix []byte, limit int, offset int, RemovePrefix bool, fn FOR_EACH_KEY_FUNC) {
store.ForEachKey(prefix, limit, offset, RemovePrefix, fn)
}