forked from xushiwei/cabinet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
239 lines (135 loc) · 5.82 KB
/
README.txt
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
PACKAGE
package cabinet
import "bitbucket.org/ww/cabinet"
Kyoto Cabinet bindings for Go. Copyleft by William Waites in 2011
This program is free software: you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation, either version
3 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
Source code: http://bitbucket.org/ww/cabinet/src
Documentation: http://godoc.styx.org/pkg/bitbucket.org/ww/cabinet
These bindings have been tested with Kyoto Cabinet version 1.2.46.
They are known not to work with 1.2.7 because of the absent
kcdbreplace() function call. Once Kyoto Cabinet is installed, building
the bindings should be a simple matter of running:
goinstall -u -v bitbucket.org/ww/cabinet
Simple usage will be along the lines of,
import (
"bitbucket.org/ww/cabinet
)
...
kc := cabinet.New()
err = kc.Open("some_db.kch", cabinet.KCOWRITER | cabinet.KCOCREATE)
err = kc.Set([]byte("hello"), []byte("world"))
world, err = kc.Get([]byte("hello"))
err = kc.Close()
kc.Del()
Obviously checking the relevant errors...
The API follows the Kyoto Cabinet C API closely, for some examples see
http://fallabs.com/kyotocabinet/api/
Most input and output variables are []byte and not string. This is because
Kyoto Cabinet is not particularly concerned with strings and it is possible
to use any byte array as either key or value. An example from the test
suite to read an integer out of the database:
var n int64
v, err = kc.Get([]byte("numbers"))
binary.Read(bytes.NewBuffer(v), binary.BigEndian, &n)
Some functions have been added for convenience using Go. The Keys()
Values() and Items() on the cursor object return a channel over which
their results will be sent, for example. This probably obviates the need
for implementing the visitor-callback pattern when using Kyoto Cabinet
with Go.
If you use this module please feel free to contact me, ww@styx.org
with any questions, comments or bug reports.
CONSTANTS
const KCEBROKEN int = C.KCEBROKEN
const KCEDUPREC int = C.KCEDUPREC
const KCEINVALID int = C.KCEINVALID
const KCELOGIC int = C.KCELOGIC
const KCEMISC = C.KCEMISC
const KCENOIMPL int = C.KCENOIMPL
const KCENOPERM int = C.KCENOPERM
const KCENOREC int = C.KCENOREC
const KCENOREPOS int = C.KCENOREPOS
const KCESUCCESS int = C.KCESUCCESS
const KCESYSTEM = C.KCESYSTEM
const KCMADD int = C.KCMADD
const KCMAPPEND int = C.KCMAPPEND
const KCMREPLACE int = C.KCMREPLACE
const KCMSET int = C.KCMSET
const KCOAUTOSYNC int = C.KCOAUTOSYNC
const KCOAUTOTRAN int = C.KCOAUTOTRAN
const KCOCREATE int = C.KCOCREATE
const KCONOLOCK int = C.KCONOLOCK
const KCONOREPAIR = C.KCONOREPAIR
const KCOREADER int = C.KCOREADER
const KCOTRUNCATE int = C.KCOTRUNCATE
const KCOTRYLOCK int = C.KCOTRYLOCK
const KCOWRITER int = C.KCOWRITER
FUNCTIONS
func EcodeName(ecode int) string
TYPES
type Item struct {
Key []byte
Value []byte
}
type KCCUR struct {
// contains unexported fields
}
func (kcc *KCCUR) Db() (kc *KCDB)
func (kcc *KCCUR) Del()
func (kcc *KCCUR) Ecode() int
func (kcc *KCCUR) Emsg() string
func (kcc *KCCUR) Get(advance bool) (k, v []byte, err os.Error)
func (kcc *KCCUR) GetKey(advance bool) (k []byte, err os.Error)
func (kcc *KCCUR) GetValue(advance bool) (v []byte, err os.Error)
func (kcc *KCCUR) Jump() (err os.Error)
func (kcc *KCCUR) JumpBack() (err os.Error)
func (kcc *KCCUR) JumpBackKey(key []byte) (err os.Error)
func (kcc *KCCUR) JumpKey(key []byte) (err os.Error)
func (kcc *KCCUR) Remove() (err os.Error)
func (kcc *KCCUR) SetValue(value []byte, advance bool) (err os.Error)
func (kcc *KCCUR) Step() (err os.Error)
func (kcc *KCCUR) StepBack() (err os.Error)
type KCDB struct {
// contains unexported fields
}
func New() *KCDB
func (kc *KCDB) Add(key, value []byte) (err os.Error)
func (kc *KCDB) Append(key, value []byte) (err os.Error)
func (kc *KCDB) BeginTran(hard bool) (err os.Error)
func (kc *KCDB) BeginTranTry(hard bool) (err os.Error)
func (kc *KCDB) Cas(key, oval, nval []byte) (err os.Error)
func (kc *KCDB) Clear() (err os.Error)
func (kc *KCDB) Close() (err os.Error)
func (kc *KCDB) Copy(filename string) (err os.Error)
func (kc *KCDB) Count() (count uint64, err os.Error)
func (kc *KCDB) Cursor() (kcc *KCCUR)
func (kc *KCDB) Del()
func (kc *KCDB) Dump(filename string) (err os.Error)
func (kc *KCDB) Ecode() int
func (kc *KCDB) EndTran(commit bool) (err os.Error)
func (kc *KCDB) Get(key []byte) (value []byte, err os.Error)
func (kc *KCDB) IncrDouble(key []byte, amount float64) (err os.Error)
func (kc *KCDB) IncrInt(key []byte, amount int64) (err os.Error)
func (kc *KCDB) Items() (out chan *Item)
func (kc *KCDB) Keys() (out chan []byte)
func (kc *KCDB) Load(filename string) (err os.Error)
func (kc *KCDB) MatchPrefix(prefix string, max int) (matches [][]byte, err os.Error)
func (kc *KCDB) MatchRegex(regex string, max int) (matches [][]byte, err os.Error)
func (kc *KCDB) Merge(sdbs []*KCDB, mode int) (err os.Error)
func (kc *KCDB) Open(filename string, mode int) (err os.Error)
func (kc *KCDB) Path() (path string, err os.Error)
func (kc *KCDB) Remove(key []byte) (err os.Error)
func (kc *KCDB) Replace(key, value []byte) (err os.Error)
func (kc *KCDB) Set(key, value []byte) (err os.Error)
func (kc *KCDB) Size() (size uint64, err os.Error)
func (kc *KCDB) Status() (status string, err os.Error)
func (kc *KCDB) Sync(hard bool) (err os.Error)
func (kc *KCDB) Values() (out chan []byte)
SUBDIRECTORIES
.hg