From 887e91375e0ae32bcc65f0363d7577878cd42610 Mon Sep 17 00:00:00 2001 From: rfyiamcool Date: Tue, 19 Dec 2023 23:14:12 +0800 Subject: [PATCH 1/2] feat: add object fraq command Signed-off-by: rfyiamcool --- commands_test.go | 3 +++ generic_commands.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/commands_test.go b/commands_test.go index 309ba1eb0..150b48ef7 100644 --- a/commands_test.go +++ b/commands_test.go @@ -675,6 +675,9 @@ var _ = Describe("Commands", func() { Expect(refCount.Err()).NotTo(HaveOccurred()) Expect(refCount.Val()).To(Equal(int64(1))) + freq := client.ObjectFreq(ctx, "key") + Expect(freq.Err()).NotTo(HaveOccurred()) + err := client.ObjectEncoding(ctx, "key").Err() Expect(err).NotTo(HaveOccurred()) diff --git a/generic_commands.go b/generic_commands.go index bf1fb47d1..dc6c3fe01 100644 --- a/generic_commands.go +++ b/generic_commands.go @@ -19,6 +19,7 @@ type GenericCmdable interface { Keys(ctx context.Context, pattern string) *StringSliceCmd Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd Move(ctx context.Context, key string, db int) *BoolCmd + ObjectFreq(ctx context.Context, key string) *IntCmd ObjectRefCount(ctx context.Context, key string) *IntCmd ObjectEncoding(ctx context.Context, key string) *StringCmd ObjectIdleTime(ctx context.Context, key string) *DurationCmd @@ -159,6 +160,12 @@ func (c cmdable) Move(ctx context.Context, key string, db int) *BoolCmd { return cmd } +func (c cmdable) ObjectFreq(ctx context.Context, key string) *IntCmd { + cmd := NewIntCmd(ctx, "object", "freq", key) + _ = c(ctx, cmd) + return cmd +} + func (c cmdable) ObjectRefCount(ctx context.Context, key string) *IntCmd { cmd := NewIntCmd(ctx, "object", "refcount", key) _ = c(ctx, cmd) From 5946693ea8c6c91f4c7b3b18ed72cd7770ab46ce Mon Sep 17 00:00:00 2001 From: rfyiamcool Date: Tue, 19 Dec 2023 23:39:21 +0800 Subject: [PATCH 2/2] feat: add object fraq command Signed-off-by: rfyiamcool --- commands_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands_test.go b/commands_test.go index 150b48ef7..f0c6d5fe9 100644 --- a/commands_test.go +++ b/commands_test.go @@ -675,8 +675,10 @@ var _ = Describe("Commands", func() { Expect(refCount.Err()).NotTo(HaveOccurred()) Expect(refCount.Val()).To(Equal(int64(1))) + client.ConfigSet(ctx, "maxmemory-policy", "volatile-lfu") freq := client.ObjectFreq(ctx, "key") Expect(freq.Err()).NotTo(HaveOccurred()) + client.ConfigSet(ctx, "maxmemory-policy", "noeviction") // default err := client.ObjectEncoding(ctx, "key").Err() Expect(err).NotTo(HaveOccurred())