Skip to content

Commit

Permalink
feat(server): implement TOUCH command (#444)
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Mello <[email protected]>

Signed-off-by: Leonardo Mello <[email protected]>
  • Loading branch information
lsvmello authored Oct 31, 2022
1 parent becc0f3 commit efd307d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
* **[Ali-Akber Saifee](https://github.com/alisaifee)**
* **[Elle Y](https://github.com/inohime)**
* **[ATM SALEH](https://github.com/ATM-SALEH)**
* **[Leonardo Mello](https://github.com/lsvmello)**
4 changes: 2 additions & 2 deletions docs/api_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ with respect to Memcached and Redis APIs.
- [ ] PFMERGE

### API 3
- [ ] Generic Family
- [ ] TOUCH
- [X] Generic Family
- [X] TOUCH
- [X] HashSet Family
- [X] HSTRLEN
- [X] Server Family
Expand Down
1 change: 1 addition & 0 deletions src/server/generic_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ void GenericFamily::Register(CommandRegistry* registry) {
<< CI{"PING", CO::FAST, -1, 0, 0, 0}.HFUNC(Ping)
<< CI{"ECHO", CO::LOADING | CO::FAST, 2, 0, 0, 0}.HFUNC(Echo)
<< CI{"EXISTS", CO::READONLY | CO::FAST, -2, 1, -1, 1}.HFUNC(Exists)
<< CI{"TOUCH", CO::READONLY | CO::FAST, -2, 1, -1, 1}.HFUNC(Exists)
<< CI{"EXPIRE", CO::WRITE | CO::FAST, 3, 1, 1, 1}.HFUNC(Expire)
<< CI{"EXPIREAT", CO::WRITE | CO::FAST, 3, 1, 1, 1}.HFUNC(ExpireAt)
<< CI{"PERSIST", CO::WRITE | CO::FAST, 2, 1, 1, 1}.HFUNC(Persist)
Expand Down
1 change: 0 additions & 1 deletion src/server/generic_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class GenericFamily {
static OpResult<uint32_t> OpExists(const OpArgs& op_args, ArgSlice keys);

private:

static void Del(CmdArgList args, ConnectionContext* cntx);
static void Ping(CmdArgList args, ConnectionContext* cntx);
static void Exists(CmdArgList args, ConnectionContext* cntx);
Expand Down
11 changes: 11 additions & 0 deletions src/server/generic_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ TEST_F(GenericFamilyTest, Exists) {
EXPECT_THAT(resp, IntArg(3));
}

TEST_F(GenericFamilyTest, Touch) {
RespExpr resp;

Run({"mset", "x", "0", "y", "1"});
resp = Run({"touch", "x", "y", "x"});
EXPECT_THAT(resp, IntArg(3));

resp = Run({"touch", "z", "x", "w"});
EXPECT_THAT(resp, IntArg(1));
}

TEST_F(GenericFamilyTest, Rename) {
RespExpr resp;
string b_val(32, 'b');
Expand Down

0 comments on commit efd307d

Please sign in to comment.