1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Small style changes

This commit is contained in:
Ruben Bridgewater
2015-10-04 21:44:52 +02:00
parent 2fc54ece57
commit 7922d4eb85
28 changed files with 386 additions and 390 deletions

View File

@@ -2,12 +2,12 @@
// A simple web server that generates dyanmic content based on responses from Redis
var http = require("http"), server,
redis_client = require("redis").createClient();
var http = require('http'), server,
redis_client = require('redis').createClient();
server = http.createServer(function (request, response) {
response.writeHead(200, {
"Content-Type": "text/plain"
'Content-Type': 'text/plain'
});
var redis_info, total_requests;
@@ -15,18 +15,18 @@ server = http.createServer(function (request, response) {
redis_client.info(function (err, reply) {
redis_info = reply; // stash response in outer scope
});
redis_client.incr("requests", function (err, reply) {
redis_client.incr('requests', function (err, reply) {
total_requests = reply; // stash response in outer scope
});
redis_client.hincrby("ip", request.connection.remoteAddress, 1);
redis_client.hgetall("ip", function (err, reply) {
redis_client.hincrby('ip', request.connection.remoteAddress, 1);
redis_client.hgetall('ip', function (err, reply) {
// This is the last reply, so all of the previous replies must have completed already
response.write("This page was generated after talking to redis.\n\n" +
"Redis info:\n" + redis_info + "\n" +
"Total requests: " + total_requests + "\n\n" +
"IP count: \n");
response.write('This page was generated after talking to redis.\n\n' +
'Redis info:\n' + redis_info + '\n' +
'Total requests: ' + total_requests + '\n\n' +
'IP count: \n');
Object.keys(reply).forEach(function (ip) {
response.write(" " + ip + ": " + reply[ip] + "\n");
response.write(' ' + ip + ': ' + reply[ip] + '\n');
});
response.end();
});