前提条件
- 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