Skip to content

Commit 57d1516

Browse files
yujun411522kiviyu
authored andcommitted
Feature: add redis_lpop_count command
1 parent 41485d6 commit 57d1516

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

trpc/client/redis/cmdgen.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,10 @@ class cmdgen {
782782

783783
std::string lpop(const std::string& key) { return BinaryCmdPacket(__func__, key); }
784784

785+
// Starting with Redis version 6.2.0: Added the count argument.
786+
// More about https://redis.io/commands/lpop/
787+
std::string lpop(const std::string& key, int count) { return TernaryCmdPacket(__func__, key, std::to_string(count)); }
788+
785789
std::string lpush(const std::string& key, const std::vector<std::string>& elements) {
786790
return TernaryCmdPacket(__func__, key, elements);
787791
}

trpc/client/redis/cmdgen_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ TEST(CmdgenTest, lists) {
402402
trpc::redis::cmdgen{}.linsert("mykey1", "mykey2", "mykey3", "mykey4"));
403403
EXPECT_EQ("*2\r\n$4\r\nllen\r\n$6\r\nmykey1\r\n", trpc::redis::cmdgen{}.llen("mykey1"));
404404
EXPECT_EQ("*2\r\n$4\r\nlpop\r\n$6\r\nmykey1\r\n", trpc::redis::cmdgen{}.lpop("mykey1"));
405+
EXPECT_EQ("*3\r\n$4\r\nlpop\r\n$6\r\nmykey1\r\n$2\r\n10\r\n", trpc::redis::cmdgen{}.lpop("mykey1", 10));
405406
EXPECT_EQ("*5\r\n$5\r\nlpush\r\n$6\r\nmykey1\r\n$4\r\nkey1\r\n$4\r\nkey2\r\n$4\r\nkey3\r\n",
406407
trpc::redis::cmdgen{}.lpush("mykey1", keys));
407408
EXPECT_EQ("*5\r\n$6\r\nlpushx\r\n$6\r\nmykey1\r\n$4\r\nkey1\r\n$4\r\nkey2\r\n$4\r\nkey3\r\n",

0 commit comments

Comments
 (0)