Skip to content

Commit

Permalink
FEATURE: touch command
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesecrust committed Jul 9, 2024
1 parent b25d58e commit 0130a7d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -13093,24 +13093,23 @@ static void process_touch_command(conn *c, token_t *tokens, const size_t ntokens
size_t nkey = tokens[KEY_TOKEN].length;
ENGINE_ERROR_CODE ret = ENGINE_SUCCESS;
item_attr attr_data;
ENGINE_ITEM_ATTR attr_ids[ATTR_END];
ENGINE_ITEM_ATTR attr_id= ATTR_EXPIRETIME;
int64_t exptime=0;

set_noreply_maybe(c, tokens, ntokens);

if (! safe_strtoll(tokens[KEY_TOKEN+1].value, &exptime))
{
print_invalid_command(c, tokens, ntokens);
out_string(c, "CLIENT_ERROR bad command line format");
out_string(c, "CLIENT_ERROR bad value");
return;
}

attr_data.exptime = realtime(exptime);
attr_ids[0] = ATTR_EXPIRETIME;

if (ret == ENGINE_SUCCESS) {
ret = mc_engine.v1->setattr(mc_engine.v0, c, key, nkey,
attr_ids, 1, &attr_data, 0);
&attr_id, 1, &attr_data, 0);
CONN_CHECK_AND_SET_EWOULDBLOCK(ret, c);
if (settings.detail_enabled) {
stats_prefix_record_setattr(key, nkey);
Expand All @@ -13128,7 +13127,7 @@ static void process_touch_command(conn *c, token_t *tokens, const size_t ntokens
break;
default:
STATS_CMD_NOKEY(c, setattr);
if (ret == ENGINE_EBADVALUE) out_string(c, "ATTR_ERROR bad value");
if (ret == ENGINE_EBADVALUE) out_string(c, "CLIENT_ERROR bad value");
else handle_unexpected_errorcode_ascii(c, __func__, ret);
}

Expand Down

0 comments on commit 0130a7d

Please sign in to comment.