redis 学习(15)-- GEO

2019-06-02  本文已影响0人  希希里之海

GEO

GEO 简介

GEO 相关命令

1.geoadd key longitude latitude member [lon lat member...]
2.geopos key member1 [member2...]
3.geodist key member1 member2 [unit]
4.georadius key longitude latitude unit [withcoord] [withdist] [withhash] [COUNT count] [sort] [store key] [storedist key]
5.georadiusbymember key member radius unit [withcoord][withdist][withhash][COUNT count][sort][store key][storedist key]

演示

由于我的 redis 版本是 3.0.7,geo 功能是在 redis-3.2 后引入的,所以这里我直接贴出演示命令,就不在重装 redis 了。

127.0.0.1:6381> geoadd cities:locations 116.28 39.55 beijing
(integer) 1
127.0.0.1:6381> geoadd cities:locations 117.12 39.08 tianjin 114.29 38.02 shijiazhuang 118.01 39.38 tangshan 115.29 38.51 baoding
(integer) 4
127.0.0.1:6381> geopos cities:locations tianjin
1) 1) "117.12000042200088501"
   2) "39.0800000535766543"
127.0.0.1:6381> geodist cities:locations tianjin beijing km
"89.2061"
127.0.0.1:6379> georadiusbymember cities:locations beijing 150 km
1) "beijing"
2) "tianjin"
3) "tangshan"
4) "baoding"
上一篇 下一篇

猜你喜欢

热点阅读