diff options
author | Valery Piashchynski <[email protected]> | 2021-06-09 20:26:18 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-09 20:26:18 +0300 |
commit | b99bfbe21a0f44b1a16b9110d779719fc637127c (patch) | |
tree | 3aabdb96c86a59325d816ad64cabc967ef2c8f10 /plugins/kv/drivers/boltdb | |
parent | 8fdf05d4f360a9f6344141b273eab9d6859470e0 (diff) | |
parent | 7665167623147403d575b7e2cf125073cbe6584d (diff) |
#715 feat(protocol): use protobuf for the `kv` and `websockets` RPC callsv2.3.0-beta.3
#715 feat(protocol): use protobuf for the `kv` and `websockets` RPC calls
Diffstat (limited to 'plugins/kv/drivers/boltdb')
-rw-r--r-- | plugins/kv/drivers/boltdb/driver.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins/kv/drivers/boltdb/driver.go b/plugins/kv/drivers/boltdb/driver.go index ba873513..253b9d33 100644 --- a/plugins/kv/drivers/boltdb/driver.go +++ b/plugins/kv/drivers/boltdb/driver.go @@ -162,7 +162,7 @@ func (d *Driver) Get(key string) ([]byte, error) { return val, nil } -func (d *Driver) MGet(keys ...string) (map[string]interface{}, error) { +func (d *Driver) MGet(keys ...string) (map[string][]byte, error) { const op = errors.Op("boltdb_driver_mget") // defense if keys == nil { @@ -177,7 +177,7 @@ func (d *Driver) MGet(keys ...string) (map[string]interface{}, error) { } } - m := make(map[string]interface{}, len(keys)) + m := make(map[string][]byte, len(keys)) err := d.DB.View(func(tx *bolt.Tx) error { b := tx.Bucket(d.bucket) @@ -186,7 +186,7 @@ func (d *Driver) MGet(keys ...string) (map[string]interface{}, error) { } buf := new(bytes.Buffer) - var out string + var out []byte buf.Grow(100) for i := range keys { value := b.Get([]byte(keys[i])) @@ -200,7 +200,7 @@ func (d *Driver) MGet(keys ...string) (map[string]interface{}, error) { } m[keys[i]] = out buf.Reset() - out = "" + out = nil } } @@ -241,8 +241,8 @@ func (d *Driver) Set(items ...*kvv1.Item) error { // performance note: pass a prepared bytes slice with initial cap // we can't move buf and gob out of loop, because we need to clear both from data // but gob will contain (w/o re-init) the past data - buf := bytes.Buffer{} - encoder := gob.NewEncoder(&buf) + buf := new(bytes.Buffer) + encoder := gob.NewEncoder(buf) if errors.Is(errors.EmptyItem, err) { return errors.E(op, errors.EmptyItem) } @@ -342,7 +342,7 @@ func (d *Driver) MExpire(items ...*kvv1.Item) error { return nil } -func (d *Driver) TTL(keys ...string) (map[string]interface{}, error) { +func (d *Driver) TTL(keys ...string) (map[string]string, error) { const op = errors.Op("boltdb_driver_ttl") if keys == nil { return nil, errors.E(op, errors.NoKeys) @@ -356,7 +356,7 @@ func (d *Driver) TTL(keys ...string) (map[string]interface{}, error) { } } - m := make(map[string]interface{}, len(keys)) + m := make(map[string]string, len(keys)) for i := range keys { if item, ok := d.gc.Load(keys[i]); ok { |