Redis 3.2 feature the geohash type.
GEOADD
is used to add keys:
> GEOADD restaurants 32.0 34.0 Falafel
(integer) 1
> GEOADD restaurants 32.1 34.1 Pizza
(integer) 1
GEORADIUS
is used to make a geo query:
> GEORADIUS restaurants 32.05 34.05 100 km WITHDIST
1) 1) "Falafel"
2) "7.2230"
2) 1) "Pizza"
2) "7.2213"
However, HDEL
does not seem to work:
> HDEL restaurants Falafel
(error) WRONGTYPE Operation against a key holding the wrong kind of value
How do I delete, or set a TTL, to a key within a geo hash?
Geohashes are sorted sets, so the right command is ZREM
:
> ZREM restaurants Falafel
(integer) 1
> GEORADIUS restaurants 32.05 34.05 100 km WITHDIST
1) 1) "Pizza"
2) "7.2213"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With