From 340dbbd205d932b241b68dd46617f8136e1b1bf8 Mon Sep 17 00:00:00 2001 From: guzeng Date: Fri, 15 Oct 2021 16:33:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=97=E8=A1=A8=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redis.pb.go | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ redis.proto | 22 +++++++++++++ 2 files changed, 116 insertions(+) diff --git a/redis.pb.go b/redis.pb.go index 27afd5f..c7dbd17 100644 --- a/redis.pb.go +++ b/redis.pb.go @@ -25,6 +25,9 @@ It has these top-level messages: SSetRequest SMembersRequest SSetResponse + LSetRequest + LSetResponse + LRangeRequest */ package redisrpc @@ -377,6 +380,81 @@ func (m *SSetResponse) GetRet() int64 { return 0 } +// 列表添加值 +type LSetRequest struct { + Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Field *string `protobuf:"bytes,2,opt,name=field" json:"field,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LSetRequest) Reset() { *m = LSetRequest{} } +func (m *LSetRequest) String() string { return proto.CompactTextString(m) } +func (*LSetRequest) ProtoMessage() {} + +func (m *LSetRequest) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *LSetRequest) GetField() string { + if m != nil && m.Field != nil { + return *m.Field + } + return "" +} + +// 设置key响应结构 +type LSetResponse struct { + Ret *int64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LSetResponse) Reset() { *m = LSetResponse{} } +func (m *LSetResponse) String() string { return proto.CompactTextString(m) } +func (*LSetResponse) ProtoMessage() {} + +func (m *LSetResponse) GetRet() int64 { + if m != nil && m.Ret != nil { + return *m.Ret + } + return 0 +} + +// 列表取值 +type LRangeRequest struct { + Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Start *int64 `protobuf:"varint,2,opt,name=start" json:"start,omitempty"` + Stop *int64 `protobuf:"varint,3,opt,name=stop" json:"stop,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LRangeRequest) Reset() { *m = LRangeRequest{} } +func (m *LRangeRequest) String() string { return proto.CompactTextString(m) } +func (*LRangeRequest) ProtoMessage() {} + +func (m *LRangeRequest) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *LRangeRequest) GetStart() int64 { + if m != nil && m.Start != nil { + return *m.Start + } + return 0 +} + +func (m *LRangeRequest) GetStop() int64 { + if m != nil && m.Stop != nil { + return *m.Stop + } + return 0 +} + func init() { } @@ -389,11 +467,15 @@ type RedisService interface { HDel(in *HDelRequest, out *DelResponse) error SetExpire(in *SetExpireRequest, out *SetExpireResponse) error HGetAll(in *GetRequest, out *HGetListResponse) error + HGetList(in *GetRequest, out *HGetListResponse) error HExists(in *HGetRequest, out *DelResponse) error Exists(in *GetRequest, out *DelResponse) error SAdd(in *SSetRequest, out *SSetResponse) error SIsmember(in *SSetRequest, out *SSetResponse) error SRem(in *SSetRequest, out *SSetResponse) error + LLpush(in *LSetRequest, out *LSetResponse) error + LRpush(in *LSetRequest, out *LSetResponse) error + LRange(in *LRangeRequest, out *HGetListResponse) error } // AcceptRedisServiceClient accepts connections on the listener and serves requests @@ -489,6 +571,9 @@ func (c *RedisServiceClient) SetExpire(in *SetExpireRequest, out *SetExpireRespo func (c *RedisServiceClient) HGetAll(in *GetRequest, out *HGetListResponse) error { return c.Call("RedisService.HGetAll", in, out) } +func (c *RedisServiceClient) HGetList(in *GetRequest, out *HGetListResponse) error { + return c.Call("RedisService.HGetList", in, out) +} func (c *RedisServiceClient) HExists(in *HGetRequest, out *DelResponse) error { return c.Call("RedisService.HExists", in, out) } @@ -504,6 +589,15 @@ func (c *RedisServiceClient) SIsmember(in *SSetRequest, out *SSetResponse) error func (c *RedisServiceClient) SRem(in *SSetRequest, out *SSetResponse) error { return c.Call("RedisService.SRem", in, out) } +func (c *RedisServiceClient) LLpush(in *LSetRequest, out *LSetResponse) error { + return c.Call("RedisService.LLpush", in, out) +} +func (c *RedisServiceClient) LRpush(in *LSetRequest, out *LSetResponse) error { + return c.Call("RedisService.LRpush", in, out) +} +func (c *RedisServiceClient) LRange(in *LRangeRequest, out *HGetListResponse) error { + return c.Call("RedisService.LRange", in, out) +} // DialRedisService connects to an RedisService at the specified network address. func DialRedisService(network, addr string) (*RedisServiceClient, *rpc.Client, error) { diff --git a/redis.proto b/redis.proto index ef1d92b..ff60703 100644 --- a/redis.proto +++ b/redis.proto @@ -81,6 +81,24 @@ message SSetResponse { int64 ret = 1; } +//列表添加值 +message LSetRequest{ + string key = 1; + string field = 2; +} + +// 设置key响应结构 +message LSetResponse { + int64 ret = 1; +} + +//列表取值 +message LRangeRequest{ + string key = 1; + int64 start = 2; + int64 stop = 3; +} + // rpc方法 service RedisService { rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询 @@ -91,9 +109,13 @@ service RedisService { rpc HDel (HDelRequest) returns (DelResponse); rpc SetExpire (SetExpireRequest) returns (SetExpireResponse); //设置有效期 rpc HGetAll(GetRequest) returns (HGetListResponse); //get hash all + rpc HGetList(GetRequest) returns (HGetListResponse); //get hash all rpc HExists(HGetRequest) returns (DelResponse); //hash键是否存在 rpc Exists(GetRequest) returns (DelResponse); //键是否存在 rpc SAdd(SSetRequest) returns (SSetResponse); //添加进入集合 rpc SIsmember(SSetRequest) returns (SSetResponse); //集合中是否存在值 rpc SRem(SSetRequest) returns (SSetResponse); //集合中删除值 + rpc LLpush(LSetRequest) returns (LSetResponse); //列表头部增加值 + rpc LRpush(LSetRequest) returns (LSetResponse); //列表尾部增加值 + rpc LRange(LRangeRequest) returns (HGetListResponse); //列表尾部增加值 } \ No newline at end of file