@@ -61,17 +61,27 @@ export interface LockFactoryConfig {
6161
6262export interface LockStore {
6363 /**
64- * Save the lock in the store if not already locked
64+ * Save the lock in the store if not already locked by another owner
65+ *
66+ * @param key The key to lock
67+ * @param owner The owner of the lock
68+ * @param ttl The time to live of the lock in milliseconds. Null means no expiration
69+ *
70+ * @returns True if the lock was acquired, false otherwise
6571 */
66- save ( key : string , owner : string , ttl : number | null | undefined ) : Promise < boolean >
72+ save ( key : string , owner : string , ttl : number | null ) : Promise < boolean >
6773
6874 /**
69- * Delete the lock from the store
75+ * Delete the lock from the store if it is owned by the owner
76+ * Otherwise throws a E_LOCK_NOT_OWNED error
77+ *
78+ * @param key The key to delete
79+ * @param owner The owner of the lock
7080 */
7181 delete ( key : string , owner : string ) : Promise < void >
7282
7383 /**
74- * Force delete the lock from the store
84+ * Force delete the lock from the store. No check is made on the owner
7585 */
7686 forceRelease ( key : string ) : Promise < void >
7787
@@ -81,12 +91,13 @@ export interface LockStore {
8191 exists ( key : string ) : Promise < boolean >
8292
8393 /**
84- * Extend the lock expiration
94+ * Extend the lock expiration. Throws an error if the lock is not owned by the owner
95+ * Duration is in milliseconds
8596 */
8697 extend ( key : string , owner : string , duration : number ) : Promise < void >
8798
8899 /**
89- * Disconnect the store
100+ * Disconnect the store from the underlying storage ( when applicable )
90101 */
91102 disconnect ( ) : Promise < void >
92103}
0 commit comments