Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xgzlucario committed Oct 29, 2023
1 parent 91b8156 commit b324f5d
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ func (c *Client) SetEx(key string, val []byte, ttl time.Duration) ([]byte, error

// SetTx
func (c *Client) SetTx(key string, val []byte, ts int64) ([]byte, error) {
args, err := c.do(NewCodec(OpSetTx).Type(TypeString).Str(key).Int(ts / timeCarry).Bytes(val))
if err != nil {
return nil, err
}
return args, nil
return c.do(NewCodec(OpSetTx).Type(TypeString).Str(key).Int(ts / timeCarry).Bytes(val))
}

// Remove
Expand All @@ -62,11 +58,7 @@ func (c *Client) Rename(key, newKey string) (bool, error) {

// Get
func (c *Client) Get(key string) ([]byte, error) {
args, err := c.do(NewCodec(OpGet).Str(key))
if err != nil {
return nil, err
}
return args, nil
return c.do(NewCodec(OpGet).Str(key))
}

// Len
Expand All @@ -86,11 +78,16 @@ func (c *Client) HSet(key, field string, val []byte) error {

// HGet
func (c *Client) HGet(key, field string) ([]byte, error) {
args, err := c.do(NewCodec(OpHGet).Str(key).Str(field))
return c.do(NewCodec(OpHGet).Str(key).Str(field))
}

// HLen
func (c *Client) HLen(key string) (int, error) {
args, err := c.do(NewCodec(OpHLen).Str(key))
if err != nil {
return nil, err
return 0, err
}
return args, nil
return base.ParseInt[int](args), nil
}

// HRemove
Expand All @@ -102,15 +99,6 @@ func (c *Client) HRemove(key, field string) (bool, error) {
return args[0] == _true, nil
}

// Len
func (c *Client) HLen(key string) (int, error) {
args, err := c.do(NewCodec(OpHLen).Str(key))
if err != nil {
return 0, err
}
return base.ParseInt[int](args), nil
}

// Close
func (c *Client) Close() error {
return c.c.Close()
Expand Down

0 comments on commit b324f5d

Please sign in to comment.