Node js redis

时间:2023-03-09 23:20:04
Node js redis
const redis = require('redis');//redis
const client = redis.createClient(, '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', ); // NX是不存在时才set, XX是存在时才set, EX是秒,PX是毫秒
client.set("hello", "{\"a\":\"1\", \"b\":\"2\"}", "NX", "EX", *);

队列

client.rpush('hello11Lists','');