Skip to content

Commit 6a584c1

Browse files
ofekshenawamonkey92tvladvildanov
authored
Support Hash-field expiration for 7.4 CE RC2 (#3040)
Co-authored-by: Monkey <golang@88.com> Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
1 parent 9c1f4f0 commit 6a584c1

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ build:
3131

3232
testdata/redis:
3333
mkdir -p $@
34-
wget -qO- https://download.redis.io/releases/redis-7.4-rc1.tar.gz | tar xvz --strip-components=1 -C $@
34+
wget -qO- https://download.redis.io/releases/redis-7.4-rc2.tar.gz | tar xvz --strip-components=1 -C $@
3535

3636
testdata/redis/src/redis-server: testdata/redis
3737
cd $< && make all

commands_test.go

+28-17
Original file line numberDiff line numberDiff line change
@@ -2486,21 +2486,25 @@ var _ = Describe("Commands", func() {
24862486
})
24872487

24882488
It("should HExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
2489-
res, err := client.HExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
2489+
resEmpty, err := client.HExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
24902490
Expect(err).To(BeNil())
2491+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2492+
24912493
for i := 0; i < 100; i++ {
24922494
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
24932495
Expect(sadd.Err()).NotTo(HaveOccurred())
24942496
}
24952497

2496-
res, err = client.HExpire(ctx, "myhash", 10, "key1", "key2", "key200").Result()
2498+
res, err := client.HExpire(ctx, "myhash", 10, "key1", "key2", "key200").Result()
24972499
Expect(err).NotTo(HaveOccurred())
24982500
Expect(res).To(Equal([]int64{1, 1, -2}))
24992501
})
25002502

25012503
It("should HPExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
2502-
_, err := client.HPExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
2504+
resEmpty, err := client.HPExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
25032505
Expect(err).To(BeNil())
2506+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2507+
25042508
for i := 0; i < 100; i++ {
25052509
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
25062510
Expect(sadd.Err()).NotTo(HaveOccurred())
@@ -2512,9 +2516,10 @@ var _ = Describe("Commands", func() {
25122516
})
25132517

25142518
It("should HExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
2515-
2516-
_, err := client.HExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
2519+
resEmpty, err := client.HExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
25172520
Expect(err).To(BeNil())
2521+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2522+
25182523
for i := 0; i < 100; i++ {
25192524
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
25202525
Expect(sadd.Err()).NotTo(HaveOccurred())
@@ -2526,9 +2531,10 @@ var _ = Describe("Commands", func() {
25262531
})
25272532

25282533
It("should HPExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
2529-
2530-
_, err := client.HPExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
2534+
resEmpty, err := client.HPExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
25312535
Expect(err).To(BeNil())
2536+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2537+
25322538
for i := 0; i < 100; i++ {
25332539
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
25342540
Expect(sadd.Err()).NotTo(HaveOccurred())
@@ -2540,9 +2546,10 @@ var _ = Describe("Commands", func() {
25402546
})
25412547

25422548
It("should HPersist", Label("hash-expiration", "NonRedisEnterprise"), func() {
2543-
2544-
_, err := client.HPersist(ctx, "no_such_key", "field1", "field2", "field3").Result()
2549+
resEmpty, err := client.HPersist(ctx, "no_such_key", "field1", "field2", "field3").Result()
25452550
Expect(err).To(BeNil())
2551+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2552+
25462553
for i := 0; i < 100; i++ {
25472554
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
25482555
Expect(sadd.Err()).NotTo(HaveOccurred())
@@ -2562,9 +2569,10 @@ var _ = Describe("Commands", func() {
25622569
})
25632570

25642571
It("should HExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
2565-
2566-
_, err := client.HExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
2572+
resEmpty, err := client.HExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
25672573
Expect(err).To(BeNil())
2574+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2575+
25682576
for i := 0; i < 100; i++ {
25692577
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
25702578
Expect(sadd.Err()).NotTo(HaveOccurred())
@@ -2580,9 +2588,10 @@ var _ = Describe("Commands", func() {
25802588
})
25812589

25822590
It("should HPExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
2583-
2584-
_, err := client.HPExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
2591+
resEmpty, err := client.HPExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
25852592
Expect(err).To(BeNil())
2593+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2594+
25862595
for i := 0; i < 100; i++ {
25872596
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
25882597
Expect(sadd.Err()).NotTo(HaveOccurred())
@@ -2599,9 +2608,10 @@ var _ = Describe("Commands", func() {
25992608
})
26002609

26012610
It("should HTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
2602-
2603-
_, err := client.HTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
2611+
resEmpty, err := client.HTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
26042612
Expect(err).To(BeNil())
2613+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2614+
26052615
for i := 0; i < 100; i++ {
26062616
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
26072617
Expect(sadd.Err()).NotTo(HaveOccurred())
@@ -2617,9 +2627,10 @@ var _ = Describe("Commands", func() {
26172627
})
26182628

26192629
It("should HPTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
2620-
2621-
_, err := client.HPTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
2630+
resEmpty, err := client.HPTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
26222631
Expect(err).To(BeNil())
2632+
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
2633+
26232634
for i := 0; i < 100; i++ {
26242635
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
26252636
Expect(sadd.Err()).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)