mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
* Cache diff generation, closes #7982 * Handle cannot acquire lock * Refactor to guard
21 lines
444 B
TypeScript
21 lines
444 B
TypeScript
import Redlock from "redlock";
|
|
import Redis from "@server/storage/redis";
|
|
|
|
export class MutexLock {
|
|
// Default expiry time for qcuiring lock in milliseconds
|
|
public static defaultLockTimeout = 5000;
|
|
|
|
/**
|
|
* Returns the redlock instance
|
|
*/
|
|
public static get lock(): Redlock {
|
|
this.redlock ??= new Redlock([Redis.defaultClient], {
|
|
retryJitter: 10,
|
|
});
|
|
|
|
return this.redlock;
|
|
}
|
|
|
|
private static redlock: Redlock;
|
|
}
|