Skip to content

Node.js example (node redis)

Josh Baker edited this page Feb 21, 2017 · 1 revision

node_redis project page

Install

npm install redis

Example

All Tile38 commands should be sent using the client.send_command(name, args, callback) function.

var redis = require("redis")
var client = redis.createClient(9851, "localhost")

client.send_command(
	"SET", ["fleet", "truck1", "POINT", "33", "-115"], 
	function(err, reply){
		if (err){
			// ERROR
		}else{
			console.log(reply)
			// OK
		}
	}
)

client.send_command(
	"GET", ["fleet", "truck1"],
	function(err, reply){
		if (err){
			// ERROR
		}else{
			console.log(reply)
			// {"type":"Point","coordinates":[-115,33]}
		}
	}
)
Clone this wiki locally