Koa2-TS/test/.example.redis.js

19 lines
570 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const {
client,
save2Redis,
getByKey,
} = require("../src/service/redis/base.service");
save2Redis("key1", "i am string value");
// redis 储存时默认调用 Object.toString 而非 JSON.stringify
// save2Redis("key2", { key: "i am string value from Object.toString()" }); // value是object报参数类型错误
getByKey("key2"); // 无console输出
client.rPush("alist", "abc");
// client.rPush("alist", 123); // value是object报参数类型错误
client.lRange("alist", 0, -1, (err, v) => {
console.log(v); // 无console输出
client.disconnect();
});