This commit is contained in:
adrinr 2023-03-07 12:47:27 +01:00
parent 49493d80be
commit 84d450a931
3 changed files with 5 additions and 5 deletions

View File

@ -46,7 +46,7 @@ async function put(
{ {
type: LockType.TRY_ONCE, type: LockType.TRY_ONCE,
name: LockName.PERSIST_WRITETHROUGH, name: LockName.PERSIST_WRITETHROUGH,
nameSuffix: key, resource: key,
ttl: 1000, ttl: 1000,
}, },
async () => { async () => {

View File

@ -88,8 +88,8 @@ export const doWithLock = async <T>(
let name: string = `lock:${prefix}_${opts.name}` let name: string = `lock:${prefix}_${opts.name}`
// add additional unique name if required // add additional unique name if required
if (opts.nameSuffix) { if (opts.resource) {
name = name + `_${opts.nameSuffix}` name = name + `_${opts.resource}`
} }
// create the lock // create the lock

View File

@ -30,9 +30,9 @@ export interface LockOptions {
*/ */
ttl: number ttl: number
/** /**
* The suffix to add to the lock name for additional uniqueness * The resource to the lock name
*/ */
nameSuffix?: string resource?: string
/** /**
* This is a system-wide lock - don't use tenancy in lock key * This is a system-wide lock - don't use tenancy in lock key
*/ */