-
Notifications
You must be signed in to change notification settings - Fork 0
/
kv.go
46 lines (37 loc) · 1022 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
38
39
40
41
42
43
44
45
46
package main
import (
"context"
v1 "github.com/dbProjectRED/redimo/v1"
)
const fieldKey = "/"
func (r RedimoService) Get(ctx context.Context, request *v1.GetRequest) (*v1.GetResponse, error) {
resp, err := r.HGet(ctx, &v1.HGetRequest{
Table: request.GetTable(),
Key: request.GetKey(),
FieldName: fieldKey,
})
if err != nil {
return nil, err
}
return &v1.GetResponse{
Found: resp.GetFound(),
Value: resp.GetValue(),
}, nil
}
func (r RedimoService) Set(ctx context.Context, request *v1.SetRequest) (*v1.SetResponse, error) {
_, err := r.HSet(ctx, &v1.HSetRequest{
Table: request.GetTable(),
Key: request.GetKey(),
FieldName: fieldKey,
Value: request.GetValue(),
})
return &v1.SetResponse{}, err
}
func (r RedimoService) Del(ctx context.Context, request *v1.DelRequest) (*v1.DelResponse, error) {
_, err := r.HDel(ctx, &v1.HDelRequest{
Table: request.GetTable(),
Key: request.GetKey(),
FieldName: fieldKey,
})
return &v1.DelResponse{}, err
}