GEOHASH(3valkey)

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

✨ GEOHASH πŸ’…

okay so bestie, this is a page from the Valkey Command Manual and it's about a command called geohash. It's giving "where my little map pins at" energy. Let's go πŸ’–


🌸 NAME

geohash β€” returns members from a geospatial index as geohash strings. That's it, that's the whole job 🫢


🌈 SYNOPSIS

GEOHASH key member [member...]

πŸŽ€ DESCRIPTION

So you've got a sorted set that's secretly a geospatial index (you put stuff in there with GEOADD, which lives over in valkey-geoadd(7)), and this command hands you back valid Geohash strings that represent where one or more of those elements are actually sitting. ✨

Now, normally Valkey stores positions using its own little variation on the Geohash technique, where positions get encoded as 52 bit integers. That encoding is also different from the standard one, because the initial min and max coordinates used during encoding and decoding are different. No cap. πŸ™ˆ

But this command? This command returns a standard Geohash, as a string, exactly as described in the Wikipedia article and compatible with the geohash.org web site. Main character behaviour only. πŸ‘‘

πŸ¦‹ Geohash string properties

The command returns 11 characters Geohash strings, so literally no precision is lost compared to the Valkey internal 52 bit representation. The returned Geohashes have these properties:

  1. They can be shortened by removing characters from the right. You'll lose precision, but it will still point to the same area. Lowkey still valid πŸ’…
  2. It is possible to use them in geohash.org URLs such as http://geohash.org/<geohash-string>. That right there is an example of such a URL.
  3. Strings with a similar prefix are nearby β€” but the contrary is not true, so it's possible that strings with different prefixes are nearby too. It's giving "same neighbourhood, different vibes" 🏘️

πŸ’œ REPLY

valkey-protocol(7) Array reply: an array where each element is the Geohash corresponding to each member name passed as an argument to the command. One geohash per member, in order, periodt ✨


πŸ”₯ COMPLEXITY

O(1) for each member requested. Snappy. Iconic. πŸ“


🌟 ACL CATEGORIES

  • @geo
  • @read
  • @slow

🧚 HISTORY

  • Available since: 3.2.0 β€” a legend from the jump πŸ‘‘

⭐ EXAMPLES

127.0.0.1:6379> GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
(integer) 2
127.0.0.1:6379> GEOHASH Sicily Palermo Catania
1) "sqc8b49rny0"
2) "sqdtr74hyu0"

look at those little strings go 😭 so cute, so precise


πŸ’€ SEE ALSO


and that's the whole page bestie, no notes πŸ’– go forth and geohash responsibly πŸ¦‹

okay bye ily β€” this was Valkey 9.0.0, dated 2025-10-21, and yes GEOHASH(3valkey) ate, no crumbs left πŸŒˆπŸ’…βœ¨

πŸ“¦ where this page comes from