From efdfeaf46e9ab5a6731a6ebb3511152779f8daec Mon Sep 17 00:00:00 2001 From: guzeng Date: Sun, 23 May 2021 23:04:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- expire.go | 2 +- expire_test.go | 6 +++--- redis.pb.go | 26 +++++++++++++------------- redis.proto | 10 +++++----- string.go | 4 ++-- string_test.go | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/expire.go b/expire.go index f456e63..ac471b1 100644 --- a/expire.go +++ b/expire.go @@ -7,7 +7,7 @@ import ( /** * 使用用户名查询 */ -func SetExpire(key string, ttl uint64, url ...string) (uint64, error) { +func SetExpire(key string, ttl int64, url ...string) (uint64, error) { conn, _, err := Conn(url...) diff --git a/expire_test.go b/expire_test.go index 14ce42a..a17fb7a 100644 --- a/expire_test.go +++ b/expire_test.go @@ -7,11 +7,11 @@ import ( func Test_SetExpire(t *testing.T) { - c, err := Set("test", "33") + c, err := Set("test", "33", 50) t.Log(c) t.Log(err) - c, err = SetExpire("test", 30) - t.Log(c) + c2, err := SetExpire("test", 0) + t.Log(c2) t.Log(err) } diff --git a/redis.pb.go b/redis.pb.go index eaf6ecf..5ddbcaa 100644 --- a/redis.pb.go +++ b/redis.pb.go @@ -59,7 +59,7 @@ func (m *GetRequest) GetKey() string { type SetRequest struct { Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` - Ttl *uint64 `protobuf:"varint,3,opt,name=ttl" json:"ttl,omitempty"` + Ttl *int64 `protobuf:"varint,3,opt,name=ttl" json:"ttl,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -81,7 +81,7 @@ func (m *SetRequest) GetValue() string { return "" } -func (m *SetRequest) GetTtl() uint64 { +func (m *SetRequest) GetTtl() int64 { if m != nil && m.Ttl != nil { return *m.Ttl } @@ -190,7 +190,7 @@ func (m *HDelRequest) GetField() string { // 有效期 type SetExpireRequest struct { Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` - Expire *uint64 `protobuf:"varint,2,opt,name=expire" json:"expire,omitempty"` + Expire *int64 `protobuf:"varint,2,opt,name=expire" json:"expire,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -205,7 +205,7 @@ func (m *SetExpireRequest) GetKey() string { return "" } -func (m *SetExpireRequest) GetExpire() uint64 { +func (m *SetExpireRequest) GetExpire() int64 { if m != nil && m.Expire != nil { return *m.Expire } @@ -248,15 +248,15 @@ func (m *SetResponse) GetRet() string { // 删除key响应结构 type DelResponse struct { - Ret *uint64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"` - XXX_unrecognized []byte `json:"-"` + Ret *int64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *DelResponse) Reset() { *m = DelResponse{} } func (m *DelResponse) String() string { return proto.CompactTextString(m) } func (*DelResponse) ProtoMessage() {} -func (m *DelResponse) GetRet() uint64 { +func (m *DelResponse) GetRet() int64 { if m != nil && m.Ret != nil { return *m.Ret } @@ -265,15 +265,15 @@ func (m *DelResponse) GetRet() uint64 { // 设置key响应结构 type HSetResponse struct { - Ret *uint64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"` - XXX_unrecognized []byte `json:"-"` + Ret *int64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *HSetResponse) Reset() { *m = HSetResponse{} } func (m *HSetResponse) String() string { return proto.CompactTextString(m) } func (*HSetResponse) ProtoMessage() {} -func (m *HSetResponse) GetRet() uint64 { +func (m *HSetResponse) GetRet() int64 { if m != nil && m.Ret != nil { return *m.Ret } @@ -282,15 +282,15 @@ func (m *HSetResponse) GetRet() uint64 { // 设置key有效期 type SetExpireResponse struct { - Ret *uint64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"` - XXX_unrecognized []byte `json:"-"` + Ret *int64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"` + XXX_unrecognized []byte `json:"-"` } func (m *SetExpireResponse) Reset() { *m = SetExpireResponse{} } func (m *SetExpireResponse) String() string { return proto.CompactTextString(m) } func (*SetExpireResponse) ProtoMessage() {} -func (m *SetExpireResponse) GetRet() uint64 { +func (m *SetExpireResponse) GetRet() int64 { if m != nil && m.Ret != nil { return *m.Ret } diff --git a/redis.proto b/redis.proto index fdf2bec..b4007c5 100644 --- a/redis.proto +++ b/redis.proto @@ -9,7 +9,7 @@ message GetRequest { message SetRequest { string key = 1; string value = 2; - uint64 ttl = 3; + int64 ttl = 3; } message DelRequest { string key = 1; @@ -36,7 +36,7 @@ message HDelRequest { //有效期 message SetExpireRequest { string key = 1; - uint64 expire = 2; + int64 expire = 2; } // 使用key查询响应结构 @@ -51,16 +51,16 @@ message SetResponse { // 删除key响应结构 message DelResponse { - uint64 ret = 1; + int64 ret = 1; } // 设置key响应结构 message HSetResponse { - uint64 ret = 1; + int64 ret = 1; } // 设置key有效期 message SetExpireResponse { - uint64 ret = 1; + int64 ret = 1; } // rpc方法 diff --git a/string.go b/string.go index fe266d5..ee58af4 100644 --- a/string.go +++ b/string.go @@ -30,7 +30,7 @@ func GetString(key string, url ...string) (string, error) { } //设置 -func Set(key, value string, ttl uint64, url ...string) (string, error) { +func Set(key, value string, ttl int64, url ...string) (string, error) { conn, _, err := Conn(url...) @@ -39,7 +39,7 @@ func Set(key, value string, ttl uint64, url ...string) (string, error) { } defer conn.Close() - req := &SetRequest{proto.String(key), proto.String(value), proto.Uint64(ttl), nil} + req := &SetRequest{proto.String(key), proto.String(value), proto.Int64(ttl), nil} res := &SetResponse{} diff --git a/string_test.go b/string_test.go index 14428bd..604f3f4 100644 --- a/string_test.go +++ b/string_test.go @@ -23,7 +23,7 @@ func Test_Set(t *testing.T) { func Test_Del(t *testing.T) { - c, err := Del("test") + c, err := Del("test2") t.Log(c) t.Log(err)