ai-query对接新版freesun-agent接口的分支
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
879 B

'use strict';
module.exports = async function factory (app, conf) {
try {
if (conf.redis) {
// https://github.com/luin/ioredis
const redis = require("ioredis")
app.fs = app.fs || {}
const client = new redis(conf.redis)
client.on("error", function (err) {
app.fs.logger.error('[FS-REDIS]', `redis connect error ${conf.redis}`);
app.fs.logger.error(err)
});
client.on('connect', function () {
app.fs.logger.info(`redis connect success ${conf.redis}`);
})
// 自定义方法
client.hdelall = async (key) => {
const obj = await client.hgetall(key);
await client.hdel(key, Object.keys(obj))
}
app.fs.redis = client
}
} catch (error) {
console.error(error)
process.exit(-1)
}
}