Skip to content

PersistentAI API Documentation / @persistentai/fireflow-vfs / server / tryAdvisoryLock

Function: tryAdvisoryLock()

tryAdvisoryLock<T>(db, lockKey, callback): Promise<T | null>

Defined in: packages/fireflow-vfs/src/db/locks.ts:73

Try to acquire advisory lock without blocking. Returns immediately with true/false indicating if lock was acquired.

Uses pg_try_advisory_xact_lock() which:

  • Returns true if lock acquired, false if not available
  • Does not block
  • Lock is transaction-scoped if acquired

Type Parameters

T

T

Parameters

db

DB

Drizzle database instance

lockKey

string

Unique string identifier for the lock

callback

() => Promise<T>

Function to execute if lock is acquired

Returns

Promise<T | null>

Result of callback if lock acquired, or null if lock not available

Licensed under BUSL-1.1