Operation locks that prevent concurrent calls to the same operation are currently living in memory only. Using a OpLock table we can move them to the attached database and provide them to additional processes.
Interface:
interface LockRepository {
tryAcquireLock(key: string, ttl: number): Promise<Lock | null>;
releaseLock(key: string): Promise;
getLock(key: string): Promise<Lock | null>;
}
interface Lock {
key: string;
acquiredAt: number;
ttl: number; // milliseconds
}
Operation locks that prevent concurrent calls to the same operation are currently living in memory only. Using a OpLock table we can move them to the attached database and provide them to additional processes.
Interface:
interface LockRepository {
tryAcquireLock(key: string, ttl: number): Promise<Lock | null>;
releaseLock(key: string): Promise;
getLock(key: string): Promise<Lock | null>;
}
interface Lock {
key: string;
acquiredAt: number;
ttl: number; // milliseconds
}