Browse Source

修改字段类型

master
guzeng 3 years ago
parent
commit
3b098a4ae5
4 changed files with 7 additions and 7 deletions
  1. +3
    -3
      redis.pb.go
  2. +1
    -1
      redis.proto
  3. +2
    -2
      string.go
  4. +1
    -1
      string_test.go

+ 3
- 3
redis.pb.go View File

@ -59,7 +59,7 @@ func (m *GetRequest) GetKey() string {
type SetRequest struct { type SetRequest struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
Ttl *string `protobuf:"bytes,3,opt,name=ttl" json:"ttl,omitempty"`
Ttl *uint64 `protobuf:"varint,3,opt,name=ttl" json:"ttl,omitempty"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
} }
@ -81,11 +81,11 @@ func (m *SetRequest) GetValue() string {
return "" return ""
} }
func (m *SetRequest) GetTtl() string {
func (m *SetRequest) GetTtl() uint64 {
if m != nil && m.Ttl != nil { if m != nil && m.Ttl != nil {
return *m.Ttl return *m.Ttl
} }
return ""
return 0
} }
type DelRequest struct { type DelRequest struct {


+ 1
- 1
redis.proto View File

@ -9,7 +9,7 @@ message GetRequest {
message SetRequest { message SetRequest {
string key = 1; string key = 1;
string value = 2; string value = 2;
string ttl = 3;
uint64 ttl = 3;
} }
message DelRequest { message DelRequest {
string key = 1; string key = 1;


+ 2
- 2
string.go View File

@ -30,7 +30,7 @@ func GetString(key string, url ...string) (string, error) {
} }
//设置 //设置
func Set(key, value string, ttl string, url ...string) (string, error) {
func Set(key, value string, ttl uint64, url ...string) (string, error) {
conn, _, err := Conn(url...) conn, _, err := Conn(url...)
@ -39,7 +39,7 @@ func Set(key, value string, ttl string, url ...string) (string, error) {
} }
defer conn.Close() defer conn.Close()
req := &SetRequest{proto.String(key), proto.String(value), proto.String(ttl), nil}
req := &SetRequest{proto.String(key), proto.String(value), proto.Uint64(ttl), nil}
res := &SetResponse{} res := &SetResponse{}


+ 1
- 1
string_test.go View File

@ -15,7 +15,7 @@ func Test_Get(t *testing.T) {
func Test_Set(t *testing.T) { func Test_Set(t *testing.T) {
c, err := Set("test", "1111", "7200")
c, err := Set("test", "1111", 7200)
t.Log(c) t.Log(c)
t.Log(err) t.Log(err)


Loading…
Cancel
Save