Skip to content

Instantly share code, notes, and snippets.

@kevcodez
Created August 28, 2022 15:28
Show Gist options
  • Save kevcodez/2a20f75e8fa58a6b8fadaf4133591136 to your computer and use it in GitHub Desktop.
Save kevcodez/2a20f75e8fa58a6b8fadaf4133591136 to your computer and use it in GitHub Desktop.
Use distributed lock
// Scheduled job running at 4:30 am
cron.scheduleJob('30 4 * * *', async () => {
// Acquire distributed lock
await lockService.acquireAndExecute({ name: 'translateAssets', ttlSeconds: 60 * 60 }, async () => {
// code to translate assets
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment