Browse Source

增加获取所有hash接口

master v0.3.0
guzeng 2 years ago
parent
commit
f2b409d019
3 changed files with 28 additions and 1 deletions
  1. +1
    -1
      expire_test.go
  2. +22
    -0
      redis.pb.go
  3. +5
    -0
      redis.proto

+ 1
- 1
expire_test.go View File

@ -10,7 +10,7 @@ func Test_SetExpire(t *testing.T) {
c, err := Set("test", "33", 50)
t.Log(c)
t.Log(err)
c2, err := SetExpire("test", 0)
c2, err := SetExpire("test", 100)
t.Log(c2)
t.Log(err)


+ 22
- 0
redis.pb.go View File

@ -17,6 +17,7 @@ It has these top-level messages:
HDelRequest
SetExpireRequest
GetStringResponse
HGetListResponse
SetResponse
DelResponse
HSetResponse
@ -229,6 +230,23 @@ func (m *GetStringResponse) GetValue() string {
return ""
}
// 使用key查询响应结构
type HGetListResponse struct {
List []byte `protobuf:"bytes,1,opt,name=list" json:"list,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *HGetListResponse) Reset() { *m = HGetListResponse{} }
func (m *HGetListResponse) String() string { return proto.CompactTextString(m) }
func (*HGetListResponse) ProtoMessage() {}
func (m *HGetListResponse) GetList() []byte {
if m != nil {
return m.List
}
return nil
}
// 设置key响应结构
type SetResponse struct {
Ret *string `protobuf:"bytes,1,opt,name=ret" json:"ret,omitempty"`
@ -308,6 +326,7 @@ type RedisService interface {
HSet(in *HSetRequest, out *HSetResponse) error
HDel(in *HDelRequest, out *DelResponse) error
SetExpire(in *SetExpireRequest, out *SetExpireResponse) error
HGetAll(in *GetRequest, out *HGetListResponse) error
}
// AcceptRedisServiceClient accepts connections on the listener and serves requests
@ -400,6 +419,9 @@ func (c *RedisServiceClient) HDel(in *HDelRequest, out *DelResponse) error {
func (c *RedisServiceClient) SetExpire(in *SetExpireRequest, out *SetExpireResponse) error {
return c.Call("RedisService.SetExpire", in, out)
}
func (c *RedisServiceClient) HGetAll(in *GetRequest, out *HGetListResponse) error {
return c.Call("RedisService.HGetAll", in, out)
}
// DialRedisService connects to an RedisService at the specified network address.
func DialRedisService(network, addr string) (*RedisServiceClient, *rpc.Client, error) {


+ 5
- 0
redis.proto View File

@ -44,6 +44,10 @@ message GetStringResponse {
string value = 1;
}
// 使key查询响应结构
message HGetListResponse {
bytes list = 1;
}
// key响应结构
message SetResponse {
string ret = 1;
@ -72,4 +76,5 @@ service RedisService {
rpc HSet (HSetRequest) returns (HSetResponse);
rpc HDel (HDelRequest) returns (DelResponse);
rpc SetExpire (SetExpireRequest) returns (SetExpireResponse); //
rpc HGetAll(GetRequest) returns (HGetListResponse); //get hash all
}

Loading…
Cancel
Save