1 //创建redis连接服务对象 2 var redis = require(‘redis‘); 3 4 var redisServerIP = ‘127.0.0.1‘; 5 var redisServerPort= ‘6379‘; 6 7 function setup_redis() { 8 var client = redis.createClient(redisServerPort, redisServerIP); 9 client.on(‘error‘, function(error) { 10 console.log("RedisServer is error!\n" + error); 11 }); 12 client.on("connect", function() { 13 console.log("RedisServer is connected!"); 14 }); 15 client.on("end", function() { 16 console.log("RedisServer is end!"); 17 }); 18 return client; 19 } 20 21 module.exports.setup_redis = setup_redis;
时间: 2024-11-14 11:02:55