GEORADIUSBYMEMBER(3valkey)
GEORADIUSBYMEMBER π
okay bestie, so this is from the Valkey Command Manual, section 3valkey β it's the manual page for georadiusbymember, and yes the name is a whole mouthful, we'll get through it together π«Ά
NAME β¨
georadiusbymember β queries a geospatial index for members within a distance from a member, and optionally stores the result. it's giving "find my friends who live near this one specific friend" energy πΊοΈ
SYNOPSIS π
GEORADIUSBYMEMBER key member radius <M | KM | FT | MI> [WITHCOORD]
[WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC] [STORE key |
STOREDIST key]
DESCRIPTION πΈ
so literally, this command is exactly like GEORADIUS β same vibe, same everything β with one sole difference, and it's a big one: instead of you handing it a longitude and latitude value to be the center of the area to query, you hand it the name of a member that already exists inside the geospatial index, and that member's position becomes the center. no coordinates required, we're letting the data do the work π
the geospatial index in question is represented by the sorted set. and the position of the member you specify? yeah, that's the center of the query. periodt.
check out the example down below, and also the GEORADIUS documentation, for more info about the command and its options β bestie, the options are the whole plot π
also real talk: GEORADIUSBYMEMBER_RO exists as a read-only version of this command that you can use in replicas. more deets on the GEORADIUS page. iykyk π¦
Alternative β
GEOSEARCH and GEOSEARCHSTORE with the BYRADIUS and FROMMEMBER arguments. iconic alternatives, no cap.
REPLY π
you get one of these back:
- if no
WITH*option is specified, you get avalkey-protocol(7)Array reply of matched member names π - if
WITHCOORD,WITHDIST, orWITHHASHoptions are specified, the command returns avalkey-protocol(7)Array reply of arrays, where each sub-array represents a single item, and inside it:- 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) π
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. math girlies rise π§
ACL CATEGORIES π
@geo @slow @write
HISTORY π
- available since:
3.2.0π - changed in
6.2.0: added theANYoption forCOUNT⨠- changed in
7.0.0: added support for uppercase unit names π
EXAMPLES π
127.0.0.1:6379> GEOADD Sicily 13.583333 37.316667 "Agrigento"
(integer) 1
127.0.0.1:6379> GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
(integer) 2
127.0.0.1:6379> GEORADIUSBYMEMBER Sicily Agrigento 100 km
1) "Agrigento"
2) "Palermo"
look at that, Agrigento showed up for its own party and brought Palermo along. obsessed π
SEE ALSO π«
geoadd(3valkey), geodist(3valkey), geohash(3valkey), geopos(3valkey), georadius(3valkey), georadiusbymember_ro(3valkey), georadius_ro(3valkey), geosearch(3valkey), geosearchstore(3valkey)
okay that's the whole page bestie, you ate it up fr fr π β¨ this was valkey 9.0.0, dated 2025-10-21 β go query some geography, you've got this ππΈπ¦
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms