mirror of https://github.com/go-redis/redis.git
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>
This commit is contained in:
parent
9c1f4f0642
commit
6a584c1e2b
2
Makefile
2
Makefile
|
@ -31,7 +31,7 @@ build:
|
||||||
|
|
||||||
testdata/redis:
|
testdata/redis:
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
wget -qO- https://download.redis.io/releases/redis-7.4-rc1.tar.gz | tar xvz --strip-components=1 -C $@
|
wget -qO- https://download.redis.io/releases/redis-7.4-rc2.tar.gz | tar xvz --strip-components=1 -C $@
|
||||||
|
|
||||||
testdata/redis/src/redis-server: testdata/redis
|
testdata/redis/src/redis-server: testdata/redis
|
||||||
cd $< && make all
|
cd $< && make all
|
||||||
|
|
|
@ -2486,21 +2486,25 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
res, err := client.HExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
|
resEmpty, err := client.HExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err = client.HExpire(ctx, "myhash", 10, "key1", "key2", "key200").Result()
|
res, err := client.HExpire(ctx, "myhash", 10, "key1", "key2", "key200").Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(res).To(Equal([]int64{1, 1, -2}))
|
Expect(res).To(Equal([]int64{1, 1, -2}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HPExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HPExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
_, err := client.HPExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
|
resEmpty, err := client.HPExpire(ctx, "no_such_key", 10, "field1", "field2", "field3").Result()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2512,9 +2516,10 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
|
resEmpty, err := client.HExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
|
||||||
_, err := client.HExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
|
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2526,9 +2531,10 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HPExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HPExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
|
resEmpty, err := client.HPExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
|
||||||
_, err := client.HPExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
|
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2540,9 +2546,10 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HPersist", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HPersist", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
|
resEmpty, err := client.HPersist(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
||||||
_, err := client.HPersist(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2562,9 +2569,10 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
|
resEmpty, err := client.HExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
||||||
_, err := client.HExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2580,9 +2588,10 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HPExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HPExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
|
resEmpty, err := client.HPExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
||||||
_, err := client.HPExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2599,9 +2608,10 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
|
resEmpty, err := client.HTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
||||||
_, err := client.HTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
@ -2617,9 +2627,10 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should HPTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
It("should HPTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
|
||||||
|
resEmpty, err := client.HPTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
||||||
_, err := client.HPTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
|
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello")
|
||||||
Expect(sadd.Err()).NotTo(HaveOccurred())
|
Expect(sadd.Err()).NotTo(HaveOccurred())
|
||||||
|
|
Loading…
Reference in New Issue