egg怎么开启多个固定时间的定时任务
如题,例如在7点执行一次,12点执行一次,23点执行一次,看了文档的动态配置,
动态配置定时任务
有时候我们需要配置定时任务的参数。定时任务还有支持另一种写法:
module.exports = app => {
return {
schedule: {
interval: app.config.cacheTick,
type: 'all',
},
async task(ctx) {
const res = await ctx.curl('http://www.api.com/cache', {
contentType: 'json',
});
ctx.app.cache = res.data;
},
};
};
实在搞不懂app.config.cacheTick是怎么做到动态的,麻烦大佬帮忙解惑
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以写成 corn 表达式