1.0.14 • Published 4 years ago

lc-schedule-by-pg v1.0.14

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

lc-schedule-by-pg

持久化工作计划:当前设计,主要是为了把schedule丟到数据库中,通过添加数据库来满足添加启用或者停用schedule。

#默认值

使用方法

schedule.js

const LCSchedule = require('lc-schedule-by-pg')
const { pgConfig } = require("./config")
const logger = require('./logger')

LCSchedule.prototype.trigger = ({ event, method }) => {
  const fun = require(`./${ event }`);
  if (fun instanceof Function) {
    fun()[method]()
  } else if (fun[method] instanceof Function) {
    fun[method]()
  }
}

module.exports = new LCSchedule({ pgConfig, logger })

cachings.js

module.exports = { 
  remove(){ 
  //Do your remove biz. 
  }
}

初始化应用,app.js 添加

const mySchedule = require('./schedule')

const interval = 1;
mySchedule.addSchedule({ persistence: true, event: "cachings", method: "remove", timeUnit: "minutes", interval }).then(
    ({ triggerId }) => console.log(`启动内存定时每${ interval }分钟清理机制,triggerId:${ triggerId }。`)).catch(e => logger.error(e))
1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago