Browse Source

返回类型修改

master
guzeng 2 years ago
parent
commit
efdfeaf46e
6 changed files with 25 additions and 25 deletions
  1. +1
    -1
      expire.go
  2. +3
    -3
      expire_test.go
  3. +13
    -13
      redis.pb.go
  4. +5
    -5
      redis.proto
  5. +2
    -2
      string.go
  6. +1
    -1
      string_test.go

+ 1
- 1
expire.go View File

@ -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...)


+ 3
- 3
expire_test.go View File

@ -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)
}

+ 13
- 13
redis.pb.go View File

@ -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
}


+ 5
- 5
redis.proto View File

@ -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方法


+ 2
- 2
string.go View File

@ -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{}


+ 1
- 1
string_test.go View File

@ -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)


Loading…
Cancel
Save