index: function (req, res) {
// redis 链接
var redis = require('redis');
var client = redis.createClient('6379', '127.0.0.1');
// redis 链接错误
client.on("error", function(error) {
console.log(error);
});
//redis list使用
client.lpush('ok', 'Hello World!', function(error, res) {
if(error) {
console.log(error);
} else {
console.log(res);
}
});
// redis 验证 (reids.conf未开启验证,此项可不需要)
client.auth("foobared");
//选数据库,使用set结构
client.select('0', function(error){
if(error) {
console.log(error);
} else {
// set
client.set('str_key_0', '0', function(error, res) {
if(error) {
console.log(error);
} else {
console.log(res);
}
});
}
});
//使用hash结构
client.hmset("nodejs","zzl01","OK", function(error, res) {
if (error) {
console.log(error);
} else {
console.log(res);
}
});
//关闭连接
client.end();
return res.send("OK");
//return res.view("view_name",data)//view_name参数为空表示用当前的action
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有