mirror of https://github.com/go-redis/redis.git
feat: add hstrlen command for hash
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
This commit is contained in:
parent
4935c434b1
commit
47591c8c2d
|
@ -2421,9 +2421,10 @@ var _ = Describe("Commands", func() {
|
|||
|
||||
hStrLen := client.HStrLen(ctx, "hash", "key")
|
||||
Expect(hStrLen.Err()).NotTo(HaveOccurred())
|
||||
Expect(hStrLen.Val()).NotTo(Equal(int64(len("hello"))))
|
||||
Expect(hStrLen.Val()).To(Equal(int64(len("hello"))))
|
||||
|
||||
nonHStrLen := client.HGet(ctx, "hash", "key1")
|
||||
nonHStrLen := client.HStrLen(ctx, "hash", "keyNon")
|
||||
Expect(hStrLen.Err()).NotTo(HaveOccurred())
|
||||
Expect(nonHStrLen.Val()).To(Equal(int64(0)))
|
||||
|
||||
hDel := client.HDel(ctx, "hash", "key")
|
||||
|
|
|
@ -6,7 +6,6 @@ type HashCmdable interface {
|
|||
HDel(ctx context.Context, key string, fields ...string) *IntCmd
|
||||
HExists(ctx context.Context, key, field string) *BoolCmd
|
||||
HGet(ctx context.Context, key, field string) *StringCmd
|
||||
HStrLen(ctx context.Context, key, field string) *IntCmd
|
||||
HGetAll(ctx context.Context, key string) *MapStringStringCmd
|
||||
HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd
|
||||
HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd
|
||||
|
@ -20,6 +19,7 @@ type HashCmdable interface {
|
|||
HVals(ctx context.Context, key string) *StringSliceCmd
|
||||
HRandField(ctx context.Context, key string, count int) *StringSliceCmd
|
||||
HRandFieldWithValues(ctx context.Context, key string, count int) *KeyValueSliceCmd
|
||||
HStrLen(ctx context.Context, key, field string) *IntCmd
|
||||
}
|
||||
|
||||
func (c cmdable) HDel(ctx context.Context, key string, fields ...string) *IntCmd {
|
||||
|
@ -46,12 +46,6 @@ func (c cmdable) HGet(ctx context.Context, key, field string) *StringCmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) HStrLen(ctx context.Context, key, field string) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "hstrlen", key, field)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) HGetAll(ctx context.Context, key string) *MapStringStringCmd {
|
||||
cmd := NewMapStringStringCmd(ctx, "hgetall", key)
|
||||
_ = c(ctx, cmd)
|
||||
|
@ -179,3 +173,9 @@ func (c cmdable) HScan(ctx context.Context, key string, cursor uint64, match str
|
|||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) HStrLen(ctx context.Context, key, field string) *IntCmd {
|
||||
cmd := NewIntCmd(ctx, "hstrlen", key, field)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue