-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Implement GEORADIUS_RO command #5678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implements the GEORADIUS_RO redis command which is a read-only variant of the existing GEORADIUS command. Signed-off-by: Eric <hayter.eric@gmail.com>
Not sure what additional tests would make sense here, since this command is essentially a strict subset of |
Since the main functionality of the command has already been tested in the existing GEORADIUS tests, only smaller tests were added to ensure that all arguments associated with the store/write operations of GEORADIUS command are invalid. Signed-off-by: Eric <hayter.eric@gmail.com>
src/server/geo_family.cc
Outdated
Type type; | ||
if (read_only) { | ||
type = | ||
parser.MapNext("ASC", Type::ASC, "DESC", Type::DESC, "COUNT", Type::COUNT, "WITHCOORD", | ||
Type::WITHCOORD, "WITHDIST", Type::WITHDIST, "WITHHASH", Type::WITHHASH); | ||
} else { | ||
type = parser.MapNext("STORE", Type::STORE, "STOREDIST", Type::STOREDIST, "ASC", Type::ASC, | ||
"DESC", Type::DESC, "COUNT", Type::COUNT, "WITHCOORD", Type::WITHCOORD, | ||
"WITHDIST", Type::WITHDIST, "WITHHASH", Type::WITHHASH); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use TryMapNext
to avoid duplicating options. First try to parse RO option, if it's nullopt && you're not in RO, then you can try with the mutable options
Updated logic in parsing of arguments such that arguments for RO variants are not duplicated with the write version Signed-off-by: Eric <hayter.eric@gmail.com>
// GEORADIUS_RO should not accept arguments for storing (writing data) | ||
auto resp = | ||
Run({"GEORADIUS_RO", "Europe", "13.4050", "52.5200", "900", "KM", "STORE_DIST", "store_key"}); | ||
EXPECT_THAT(resp, ErrArg("syntax error")); | ||
|
||
resp = Run({"GEORADIUS_RO", "Europe", "13.4050", "52.5200", "900", "KM", "STORE", "store_key"}); | ||
EXPECT_THAT(resp, ErrArg("syntax error")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add one successful usage of GEORADIUS_RO, to see that it works; you don't need to write all use cases
// functionality for main GEORADIUS is already tested in the above function ensure that invalid | ||
// arguments are not accepted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this comment
Implements the
GEORADIUS_RO
command which is a read-only variant of the existingGEORADIUS
command. Resolves #3882.Command documentation can be found here.