24 lines
511 B
TypeScript
24 lines
511 B
TypeScript
import { LotteryCache } from 'common/LotteryCache'
|
|
import logger from 'logger/logger'
|
|
import * as schedule from 'node-schedule'
|
|
import { singleton } from 'zutils'
|
|
|
|
/**
|
|
* 定时更新发送邮件验证码的过期状态
|
|
*/
|
|
@singleton
|
|
export default class CacheSchedule {
|
|
async updateCache() {
|
|
try {
|
|
new LotteryCache().flush()
|
|
} catch (err) {
|
|
logger.warn(err)
|
|
}
|
|
}
|
|
scheduleAll() {
|
|
schedule.scheduleJob('*/10 * * * * *', async () => {
|
|
await this.updateCache()
|
|
})
|
|
}
|
|
}
|