nodejs连接redis
//安装 npm install redis
const redis = require('redis') //创建客户端 const redisClient = redis.createClient(6379, '127.0.0.1') redisClient.on('error', err => { console.log(err) }) //测试 //存储key值 redisClient.set('myname', 'zhangsan2', redis.print) //获取key值 redisClient.get('myname', (err, val) => { if (err) { console.log(err) return } console.log("val=", val) //退出 redisClient.quit() })