Node js redis

Claire_ljy發表於2020-04-04
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');

 

轉載於:https://www.cnblogs.com/Guroer/p/10475724.html

相關文章