What's new in Valkey 9.0? Discover new features and improvements. Read the announcement.
GEORADIUSBYMEMBER
Queries a geospatial index for members within a distance from a member, optionally stores the result.
Usage
GEORADIUSBYMEMBER key member radius unit [WITHCOORD withcoord] [WITHDIST withdist] [WITHHASH withhash] [count-block] [order] [store]
Complexity
O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
Since
3.2.0
ACL Categories
@geo, @slow, @write
Command flags
WRITE, DENYOOM
This command is exactly like GEORADIUS with the sole difference that instead
of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.
The position of the specified member is used as the center of the query.
Please check the example below and the GEORADIUS documentation for more information about the command and its options.
Note that GEORADIUSBYMEMBER_RO was added to provide a read-only command that can be used in replicas. See the GEORADIUS page for more information.
Alternative
GEOSEARCH and GEOSEARCHSTORE with the BYRADIUS and FROMMEMBER arguments.
If no WITH* option is specified, an Array reply of matched member names
If WITHCOORD, WITHDIST, or WITHHASH options are specified, the command returns an Array reply of arrays, where each sub-array represents a single item:
The distance from the center as a floating point number, in the same unit specified in the radius.
The Geohash integer.
The coordinates as a two items x,y array (longitude,latitude).
RESP3
One of the following:
If no WITH* option is specified, an Array reply of matched member names
If WITHCOORD, WITHDIST, or WITHHASH options are specified, the command returns an Array reply of arrays, where each sub-array represents a single item:
The distance from the center as a floating point number, in the same unit specified in the radius.
The Geohash integer.
The coordinates as a two items x,y array (longitude,latitude).