4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Redis3.2から追加予定のGeo hashing APIをnode.jsで利用してみた

Posted at

前提条件

  • Redis 3.2-rc3
  • Node.js 5.9.1
  • npm
    • node_redis 2.6.0-0

ソースコード

'use strict'

let redis = require("redis")
  , client = redis.createClient()
  ;

client.geoadd('Sicily', 13.361389, 38.115556, 'Palermo', 15.087269, 37.502669, 'Catania');

client.geodist('Sicily', 'Palermo', 'Catania', function (err, reply) {
    console.log(reply.toString());
});

client.georadius('Sicily', 15, 37, 100, 'km', function (err, reply) {
    console.log(reply.toString());
});

client.georadius('Sicily', 15, 37, 200, 'km', function (err, reply) {
    console.log(reply.toString());
});

client.quit();

実行結果

166274.15156960033
Catania
Palermo,Catania

参考資料

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?