Redis系列第五篇之Geo

2022-06-24  本文已影响0人  pyihe

前言

Redis Commands页面中,Redis还提供了一种名为Geospatial indices的命令,该命令是用于地理空间索引,目的是为了方便在给定的地理半径内查找位置。调用方可以通过GEOADD添加地理位置,通过GEORADIUS命令来查找指定半径范围内的位置。虽然Redis将其定义为地理空间索引,但实质上此命令对应的数据类型为Sorted Set(有序集合)。接下来是地理位置空间索引相关的命令~

GEOADD key [ NX | XX] [CH] longitude latitude member [ longitude latitude member ...]

GEODIST key member1 member2 [ M | KM | FT | MI]

GEOHASH key member [member ...]

GEOPOS key member [member ...]

GEORADIUS key longitude latitude radius M | KM | FT | MI [WITHCOORD] [WITHDIST] [WITHHASH] [ COUNT count [ANY]] [ ASC | DESC] [STORE key] [STOREDIST key]

GEORADIUS_RO key longitude latitude radius M | KM | FT | MI [WITHCOORD] [WITHDIST] [WITHHASH] [ COUNT count [ANY]] [ ASC | DESC]

GEORADIUSBYMEMBER key member radius M | KM | FT | MI [WITHCOORD] [WITHDIST] [WITHHASH] [ COUNT count [ANY]] [ ASC | DESC] [STORE key] [STOREDIST key]

GEORADIUSBYMEMBER_RO key member radius M | KM | FT | MI [WITHCOORD] [WITHDIST] [WITHHASH] [ COUNT count [ANY]] [ ASC | DESC]

GEOSEARCH key FROMMEMBER member | FROMLONLAT longitude latitude BYRADIUS radius M | KM | FT | MI | BYBOX width height M | KM | FT | MI [ ASC | DESC] [ COUNT count [ANY]] [WITHCOORD] [WITHDIST] [WITHHASH]

GEOSEARCHSTORE destination source FROMMEMBER member | FROMLONLAT longitude latitude BYRADIUS radius M | KM | FT | MI | BYBOX width height M | KM | FT | MI [ ASC | DESC] [ COUNT count [ANY]] [STOREDIST]

参考资料

Redis GEO
原文链接

上一篇下一篇

猜你喜欢

热点阅读