nodejs总结之redis模块

2021-07-09 09:06

阅读:596

标签:connect   create   server   服务   exp   模块   color   console   err   

 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;

 

nodejs总结之redis模块

标签:connect   create   server   服务   exp   模块   color   console   err   

原文地址:http://www.cnblogs.com/atp-sir/p/7094275.html


评论


亲,登录后才可以留言!