redis-geo

作者: zhangsanzhu | 来源:发表于2018-12-29 09:32 被阅读0次

    redis-geo

    介绍

    • 算法看geo那个
    • 内部实现就是zset(skiplist)

    实例

    //增加ireader的坐标
    127.0.0.1:6379> geoadd company 116.514203 39.905409 ireader 
    (integer) 1
    
    //增加美团的坐标
    127.0.0.1:6379> geoadd company 116.489033 40.007669 meituan
    (integer) 1
    127.0.0.1:6379> geoadd company 116.562108 39.787602 jd 116.334255 40.027400 xiaomi
    (integer) 2
    //查看掘金和掌阅的距离
    127.0.0.1:6379> geodist company juejin ireader km
    "10.5501"
    
    //查看掘金的坐标
    127.0.0.1:6379>  geopos company juejin
    1) 1) "116.48104995489120483"
       2) "39.99679348858259686"
       
    //获取小米的geohash编码
    127.0.0.1:6379> geohash company xiaomi
    1) "wx4exqb0880"
    127.0.0.1:6379> geohash company meituan
    1) "wx4gdg0tx40"
    127.0.0.1:6379>
    

    相关文章

      网友评论

          本文标题:redis-geo

          本文链接:https://www.haomeiwen.com/subject/nofulqtx.html