diff --git a/redis.pb.go b/redis.pb.go index 7446ab3..eaf6ecf 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 *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:"-"` } @@ -81,11 +81,11 @@ func (m *SetRequest) GetValue() string { return "" } -func (m *SetRequest) GetTtl() string { +func (m *SetRequest) GetTtl() uint64 { if m != nil && m.Ttl != nil { return *m.Ttl } - return "" + return 0 } type DelRequest struct { diff --git a/redis.proto b/redis.proto index aa0a5e2..fdf2bec 100644 --- a/redis.proto +++ b/redis.proto @@ -9,7 +9,7 @@ message GetRequest { message SetRequest { string key = 1; string value = 2; - string ttl = 3; + uint64 ttl = 3; } message DelRequest { string key = 1; diff --git a/string.go b/string.go index 1cec089..fe266d5 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 string, url ...string) (string, error) { +func Set(key, value string, ttl uint64, url ...string) (string, error) { conn, _, err := Conn(url...) @@ -39,7 +39,7 @@ func Set(key, value string, ttl string, url ...string) (string, error) { } 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{} diff --git a/string_test.go b/string_test.go index 647e93a..14428bd 100644 --- a/string_test.go +++ b/string_test.go @@ -15,7 +15,7 @@ func Test_Get(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(err)