主要用来跑一些定时任务,比如获取某些服务配置

schedule写法(官网中有两种写法):

// app/schedule/setting.js

export default { schedule: { interval: '10s', // 每10 秒 执行一次 type: 'all', // specify all `workers` need to execute },
  //这个task是约定好的,而且必须是async函数 async task(ctx) { const settings
= await ctx.service.ducc.getSetting() //具体的数据格式是自己决定的 if (settings && settings.data && settings.data.length > 0) { global.cache.ducc= setttings.data; } } }, };

 

相关文章:

  • 2021-12-17
  • 2021-06-22
  • 2021-05-30
  • 2022-01-10
  • 2021-06-17
  • 2021-09-04
  • 2021-07-09
  • 2022-01-05
猜你喜欢
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2021-07-09
  • 2022-02-28
  • 2021-10-24
  • 2021-07-07
相关资源
相似解决方案