@clonegod/ttd-bsc-common 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,7 +10,7 @@ export declare class SimpleRedisClient {
|
|
|
10
10
|
private getLockKey;
|
|
11
11
|
private acquireLock;
|
|
12
12
|
private releaseLock;
|
|
13
|
-
withLock<T>(lock_identifier: string, callback: () => Promise<T
|
|
13
|
+
withLock<T>(lock_identifier: string, callback: () => Promise<T>, release_lock_delay_ms?: number): Promise<T>;
|
|
14
14
|
getValue(key: string): Promise<string>;
|
|
15
15
|
setValue(key: string, value: string, expireSeconds: number): Promise<any>;
|
|
16
16
|
hsetValue(key: string, field: string, value: string, expireSeconds: number): Promise<any>;
|
|
@@ -69,8 +69,8 @@ class SimpleRedisClient {
|
|
|
69
69
|
return success;
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
withLock(
|
|
73
|
-
return __awaiter(this,
|
|
72
|
+
withLock(lock_identifier_1, callback_1) {
|
|
73
|
+
return __awaiter(this, arguments, void 0, function* (lock_identifier, callback, release_lock_delay_ms = 2000) {
|
|
74
74
|
const lock_key = this.getLockKey(lock_identifier);
|
|
75
75
|
const lock_value = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
76
76
|
let retries = 0;
|
|
@@ -90,7 +90,7 @@ class SimpleRedisClient {
|
|
|
90
90
|
}
|
|
91
91
|
finally {
|
|
92
92
|
if (acquired) {
|
|
93
|
-
yield (0, dist_1.sleep)(parseInt(process.env.NONCE_LOCK_RELEASE_DELAY_MS ||
|
|
93
|
+
yield (0, dist_1.sleep)(parseInt(process.env.NONCE_LOCK_RELEASE_DELAY_MS || String(release_lock_delay_ms)));
|
|
94
94
|
yield this.releaseLock(lock_key, lock_value);
|
|
95
95
|
}
|
|
96
96
|
}
|