Skip to content

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EricHayter
Copy link
Contributor

Implements the GEORADIUS_RO command which is a read-only variant of the existing GEORADIUS command. Resolves #3882.

Command documentation can be found here.

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>
@EricHayter
Copy link
Contributor Author

EricHayter commented Aug 16, 2025

Not sure what additional tests would make sense here, since this command is essentially a strict subset of GEORADIUS and most of the core logic is already covered. I will add some miscellaneous tests to cover argument handling.

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>
Comment on lines 790 to 799
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);
}
Copy link
Contributor

@dranikpg dranikpg Aug 16, 2025

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>
@EricHayter EricHayter requested a review from dranikpg August 19, 2025 11:45
Comment on lines +306 to +312
// 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"));
Copy link
Contributor

@BorysTheDev BorysTheDev Aug 19, 2025

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

Comment on lines +297 to +298
// functionality for main GEORADIUS is already tested in the above function ensure that invalid
// arguments are not accepted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement GEORADIUS_RO
3 participants