GEORADIUSBYMEMBER(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

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 a valkey-protocol(7) Array reply of matched member names πŸ‘‘
  • if WITHCOORD, WITHDIST, or WITHHASH options are specified, the command returns a valkey-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 the ANY option for COUNT ✨
  • 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