From f5cf9857c6aa0fc27c2cda9f587704a103339efe Mon Sep 17 00:00:00 2001 From: jianbin Date: Wed, 17 Apr 2024 18:22:53 +0800 Subject: [PATCH] feature: support hlen protocol --- .../handler/process/impl/hash/HLenRequestProcessor.java | 2 +- src/main/resources/lua/hlen.lua | 2 +- src/test/java/icu/funkye/redispike/ServerTest.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/icu/funkye/redispike/handler/process/impl/hash/HLenRequestProcessor.java b/src/main/java/icu/funkye/redispike/handler/process/impl/hash/HLenRequestProcessor.java index cabfe2a..c6c2986 100644 --- a/src/main/java/icu/funkye/redispike/handler/process/impl/hash/HLenRequestProcessor.java +++ b/src/main/java/icu/funkye/redispike/handler/process/impl/hash/HLenRequestProcessor.java @@ -63,6 +63,6 @@ public void onFailure(AerospikeException exception) { logger.error(exception.getMessage(), exception); write(ctx, request); } - }, client.getWritePolicyDefault(), key, "hlen", "count_bins"); + }, client.getWritePolicyDefault(), key, "hlen", "hash_count_bins"); } } diff --git a/src/main/resources/lua/hlen.lua b/src/main/resources/lua/hlen.lua index 6f24106..b6163be 100644 --- a/src/main/resources/lua/hlen.lua +++ b/src/main/resources/lua/hlen.lua @@ -1,4 +1,4 @@ -function count_bins(rec) +function hash_count_bins(rec) local bins = record.bin_names(rec) local bin_count = #bins return bin_count diff --git a/src/test/java/icu/funkye/redispike/ServerTest.java b/src/test/java/icu/funkye/redispike/ServerTest.java index ffe813e..703d371 100644 --- a/src/test/java/icu/funkye/redispike/ServerTest.java +++ b/src/test/java/icu/funkye/redispike/ServerTest.java @@ -160,8 +160,8 @@ public void testhHash() { map.put("d", "e"); result = jedis.hset(key, map); Assertions.assertEquals(result, 2); - /* result = jedis.hlen(key); - Assertions.assertEquals(result, map.size());*/ + result = jedis.hlen(key); + Assertions.assertEquals(result, map.size()); List list = jedis.hmget(key, "b", "d"); Assertions.assertEquals(list.size(), 2); list = jedis.hvals(key);