File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -213,5 +213,13 @@ func (b *Bolt) Close() error {
213
213
}
214
214
215
215
func (b * Bolt ) Batch (kvs map [string ][]byte ) error {
216
- panic ("Not support" )
216
+ return b .engine .Batch (func (tx * bolt.Tx ) error {
217
+ bucket := tx .Bucket ([]byte (GLOBAL ))
218
+ for k , v := range kvs {
219
+ if err := bucket .Put ([]byte (k ), v ); err != nil {
220
+ return err
221
+ }
222
+ }
223
+ return nil
224
+ })
217
225
}
Original file line number Diff line number Diff line change @@ -71,6 +71,16 @@ func bolt1() {
71
71
for _ , i := range res {
72
72
fmt .Printf ("suffix...%v...%s\n " , len (res ), string (i ))
73
73
}
74
+ kvs := make (map [string ][]byte )
75
+ kvs ["batch1" ] = []byte ("batchv1" )
76
+ kvs ["batch2" ] = []byte ("batchv2" )
77
+ kvs ["batch3" ] = []byte ("batchv3" )
78
+ kvs ["batch4" ] = []byte ("batchv4" )
79
+ db .Batch (kvs )
80
+ res = db .Prefix ([]byte ("batch" ))
81
+ for _ , i := range res {
82
+ fmt .Printf ("prefix(batch)...%v...%s\n " , len (res ), string (i ))
83
+ }
74
84
res = db .Scan ()
75
85
for _ , i := range res {
76
86
fmt .Printf ("scan...%v...%v\n " , len (res ), len (i ))
You can’t perform that action at this time.
0 commit comments