1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

feat(server): implement TOUCH command (#444)

Signed-off-by: Leonardo Mello <lsvmello@gmail.com>

Signed-off-by: Leonardo Mello <lsvmello@gmail.com>
This commit is contained in:
Leonardo Mello 2022-10-31 16:07:13 -03:00 committed by GitHub
parent becc0f38c0
commit efd307dbb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 3 deletions

View file

@ -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)**

View file

@ -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

View file

@ -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)

View file

@ -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);

View file

@ -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');