1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-12 14:21:52 +03:00

feat: add hstrlen command for hash (#2843)

* feat: add hstrlen command for hash

Signed-off-by: rfyiamcool <rfyiamcool@163.com>

* feat: add hstrlen command for hash

Signed-off-by: rfyiamcool <rfyiamcool@163.com>

---------

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
This commit is contained in:
fengyun.rui
2025-03-04 19:31:45 +08:00
committed by GitHub
parent ebe11d06ca
commit cd55713972
2 changed files with 24 additions and 0 deletions

View File

@ -2626,6 +2626,23 @@ var _ = Describe("Commands", func() {
))
})
It("should HStrLen", func() {
hSet := client.HSet(ctx, "hash", "key", "hello")
Expect(hSet.Err()).NotTo(HaveOccurred())
hStrLen := client.HStrLen(ctx, "hash", "key")
Expect(hStrLen.Err()).NotTo(HaveOccurred())
Expect(hStrLen.Val()).To(Equal(int64(len("hello"))))
nonHStrLen := client.HStrLen(ctx, "hash", "keyNon")
Expect(hStrLen.Err()).NotTo(HaveOccurred())
Expect(nonHStrLen.Val()).To(Equal(int64(0)))
hDel := client.HDel(ctx, "hash", "key")
Expect(hDel.Err()).NotTo(HaveOccurred())
Expect(hDel.Val()).To(Equal(int64(1)))
})
It("should HExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
res, err := client.HExpire(ctx, "no_such_key", 10*time.Second, "field1", "field2", "field3").Result()
@ -2642,6 +2659,7 @@ var _ = Describe("Commands", func() {
Expect(res).To(Equal([]int64{1, 1, -2}))
})
It("should HPExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
res, err := client.HPExpire(ctx, "no_such_key", 10*time.Second, "field1", "field2", "field3").Result()