Redis select insert error

  node.js, question

Beginners redis, wrote a small demo, the expected goal: db0-db9 insert a piece of data each, the reality is that all are inserted into db9, please help to see, thank you.

App.js provides services:

var express = require("express");
 var bodyParser = require('body-parser');
 
 var redis = require("redis");
 var client = redis.createClient("6379","192.168.205.161");
 
 var app = express();
 app.use(bodyParser());
 
 app.post("/",function(req,res){
 client.SELECT(req.body.id,function(){
 client.HMSET(req.body.id,req.body,function(err){
 if(err){
 Log ("insert failed");
 return false;
 bracket
 Log ("insert succeeded");
 client.EXPIRE(req.body.id,86400);
 });
 })
 });
 
 app.listen("3001");

utilizerequestThe module emulates post requests

var request = require("request");
 
 for(var i = 0;  i<10;  I plus)
 (function(i){
 request.post({
 url:'http://127.0.0.1:3001/',
 json:{'id':i}
 });
 })(i);
 bracket

图片描述

Try

var request = require("request");
 
 for(let i = 0;  i<10;  I plus)
 (function(i){
 request.post({
 url:'http://127.0.0.1:3001/',
 json:{'id':i}
 });
 })(i);
 bracket