Public
Like
simpleSqliteLock
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
This lock works by checking to see if another Val has attempted to acquire the lock within the last N seconds. If any have, it returns an error. This doesn't allow for releasing locks, and is mostly to help with simple cases where you want to make sure two executions don't start within a specific time window.
You could use it in a cron like so:
import { SqliteLock } from "https://esm.town/v/maxm/simpleSqliteLock/lock";
const twoMinutes = 120;
const lock = new SqliteLock(projectVal.name, twoMinutes);
export default async function(interval: Interval) {
await lock.lock()
}
Cron