Browse Source

设置KEY增加过期时间

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

+ 6
- 6
redis.pb.go View File

@ -203,7 +203,7 @@ func (m *GetStringResponse) GetValue() string {
// 设置key响应结构
type SetResponse struct {
Ret *uint64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"`
Ret *string `protobuf:"bytes,1,opt,name=ret" json:"ret,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
@ -211,16 +211,16 @@ func (m *SetResponse) Reset() { *m = SetResponse{} }
func (m *SetResponse) String() string { return proto.CompactTextString(m) }
func (*SetResponse) ProtoMessage() {}
func (m *SetResponse) GetRet() uint64 {
func (m *SetResponse) GetRet() string {
if m != nil && m.Ret != nil {
return *m.Ret
}
return 0
return ""
}
// 删除key响应结构
type DelResponse struct {
Ret *uint64 `protobuf:"varint,1,opt,name=ret" json:"ret,omitempty"`
Ret *string `protobuf:"bytes,1,opt,name=ret" json:"ret,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
@ -228,11 +228,11 @@ 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() string {
if m != nil && m.Ret != nil {
return *m.Ret
}
return 0
return ""
}
func init() {


+ 2
- 2
redis.proto View File

@ -40,12 +40,12 @@ message GetStringResponse {
// key响应结构
message SetResponse {
uint64 ret = 1;
string ret = 1;
}
// key响应结构
message DelResponse {
uint64 ret = 1;
string ret = 1;
}
// rpc方法
service RedisService {


+ 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) (uint64, error) {
func Set(key, value string, ttl string, url ...string) (string, error) {
conn, _, err := Conn(url...)
@ -53,7 +53,7 @@ func Set(key, value string, ttl string, url ...string) (uint64, error) {
}
//设置
func Del(key string, url ...string) (uint64, error) {
func Del(key string, url ...string) (string, error) {
conn, _, err := Conn(url...)


+ 6
- 6
string_test.go View File

@ -15,16 +15,16 @@ import (
func Test_Set(t *testing.T) {
c, err := Set("test", "1111", 7200)
c, err := Set("test", "1111", "7200")
t.Log(c)
t.Log(err)
}
// func Test_Del(t *testing.T) {
func Test_Del(t *testing.T) {
// c, err := Del("test")
// t.Log(c)
// t.Log(err)
c, err := Del("test")
t.Log(c)
t.Log(err)
// }
}

Loading…
Cancel
Save