XTRIM: Parse args before lookupKey (#8550)
This aligns better with other commands, specifically XADD
This commit is contained in:
parent
c307ce826a
commit
a4e3ddd33c
@ -3229,17 +3229,17 @@ cleanup:
|
|||||||
void xtrimCommand(client *c) {
|
void xtrimCommand(client *c) {
|
||||||
robj *o;
|
robj *o;
|
||||||
|
|
||||||
|
/* Argument parsing. */
|
||||||
|
streamAddTrimArgs parsed_args;
|
||||||
|
if (streamParseAddOrTrimArgsOrReply(c, &parsed_args, 1) < 0)
|
||||||
|
return; /* streamParseAddOrTrimArgsOrReply already replied. */
|
||||||
|
|
||||||
/* If the key does not exist, we are ok returning zero, that is, the
|
/* If the key does not exist, we are ok returning zero, that is, the
|
||||||
* number of elements removed from the stream. */
|
* number of elements removed from the stream. */
|
||||||
if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL
|
if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL
|
||||||
|| checkType(c,o,OBJ_STREAM)) return;
|
|| checkType(c,o,OBJ_STREAM)) return;
|
||||||
stream *s = o->ptr;
|
stream *s = o->ptr;
|
||||||
|
|
||||||
/* Argument parsing. */
|
|
||||||
streamAddTrimArgs parsed_args;
|
|
||||||
if (streamParseAddOrTrimArgsOrReply(c, &parsed_args, 1) < 0)
|
|
||||||
return; /* streamParseAddOrTrimArgsOrReply already replied. */
|
|
||||||
|
|
||||||
/* Perform the trimming. */
|
/* Perform the trimming. */
|
||||||
int64_t deleted = streamTrim(s, &parsed_args);
|
int64_t deleted = streamTrim(s, &parsed_args);
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user