From baeafb732c9c99807e4d8e24c79eda32204d7de8 Mon Sep 17 00:00:00 2001 From: guzeng Date: Tue, 30 Nov 2021 17:29:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E9=87=8F=E5=8A=A0=E5=87=8F=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redis.pb.go | 34 ++++++++++++++++++++++++++++++++++ redis.proto | 7 +++++++ 2 files changed, 41 insertions(+) diff --git a/redis.pb.go b/redis.pb.go index d929dd2..815d6bb 100644 --- a/redis.pb.go +++ b/redis.pb.go @@ -29,6 +29,7 @@ It has these top-level messages: LSetResponse LRangeRequest LLenRequest + AddRequest */ package redisrpc @@ -473,6 +474,31 @@ func (m *LLenRequest) GetKey() string { return "" } +// 数值增加 +type AddRequest struct { + Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Value *int64 `protobuf:"varint,2,opt,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AddRequest) Reset() { *m = AddRequest{} } +func (m *AddRequest) String() string { return proto.CompactTextString(m) } +func (*AddRequest) ProtoMessage() {} + +func (m *AddRequest) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *AddRequest) GetValue() int64 { + if m != nil && m.Value != nil { + return *m.Value + } + return 0 +} + func init() { } @@ -498,6 +524,8 @@ type RedisService interface { LRange(in *LRangeRequest, out *HGetListResponse) error LLen(in *LLenRequest, out *LSetResponse) error ReduceStock(in *SetRequest, out *SetResponse) error + Incrby(in *AddRequest, out *SetResponse) error + Decrby(in *AddRequest, out *SetResponse) error } // AcceptRedisServiceClient accepts connections on the listener and serves requests @@ -632,6 +660,12 @@ func (c *RedisServiceClient) LLen(in *LLenRequest, out *LSetResponse) error { func (c *RedisServiceClient) ReduceStock(in *SetRequest, out *SetResponse) error { return c.Call("RedisService.ReduceStock", in, out) } +func (c *RedisServiceClient) Incrby(in *AddRequest, out *SetResponse) error { + return c.Call("RedisService.Incrby", in, out) +} +func (c *RedisServiceClient) Decrby(in *AddRequest, out *SetResponse) error { + return c.Call("RedisService.Decrby", 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 2c02d1c..cdc19e1 100644 --- a/redis.proto +++ b/redis.proto @@ -103,6 +103,11 @@ message LLenRequest{ string key = 1; } +//数值增加 +message AddRequest { + string key = 1; + int64 value = 2; +} // rpc方法 service RedisService { rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询 @@ -126,4 +131,6 @@ service RedisService { rpc LRange(LRangeRequest) returns (HGetListResponse); //列表尾部增加值 rpc LLen(LLenRequest) returns (LSetResponse); //列表长度 rpc ReduceStock(SetRequest) returns(SetResponse);//扣减库存 + rpc Incrby(AddRequest) returns(SetResponse);//增加 + rpc Decrby(AddRequest) returns(SetResponse);//减 } \ No newline at end of file