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');