如何从redis geohash中删除项目?

时间:2016-08-31 15:46:57

标签: hash redis geo redis-3.2

Redis 3.2具有geohash类型。

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用于制作地理位置查询:

> GEORADIUS restaurants 32.05 34.05 100 km WITHDIST
1) 1) "Falafel"
   2) "7.2230"
2) 1) "Pizza"
   2) "7.2213"

但是,HDEL似乎不起作用:

> HDEL restaurants Falafel
(error) WRONGTYPE Operation against a key holding the wrong kind of value

如何删除或设置TTL到地理哈希中的键?

1 个答案:

答案 0 :(得分:2)

Geohashes是排序集,因此right command is ZREM

> ZREM restaurants Falafel
(integer) 1

> GEORADIUS restaurants 32.05 34.05 100 km WITHDIST
1) 1) "Pizza"
   2) "7.2213"