首页 > Web开发 > 详细

Node js redis

时间:2019-03-05 12:38:22      阅读:153      评论:0      收藏:0      [点我收藏+]
const redis = require(redis);//redis
const client = redis.createClient(8888, 172.16.4.2);
  //redis操作
  client.set("hello", "{\"a\":\"1\", \"b\":\"2\"}") 
  client.get("hello", function(err, value){
       console.log(value);
  
       jsonObj = JSON.parse(value);//将字符串转换为json对象
       console.log(jsonObj.a);
  
   })
   client.expire(hello, 3);

   // NX是不存在时才set, XX是存在时才set, EX是秒,PX是毫秒
   client.set("hello", "{\"a\":\"1\", \"b\":\"2\"}", "NX", "EX", 60*10);

队列

client.rpush(hello11Lists,1);

 

Node js redis

原文:https://www.cnblogs.com/Guroer/p/10475724.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!