xdmp.lockAcquire( uri as String, [scope as String?], [depth as String?], [owner as Sequence], [timeout as (Number|String)?] ) as null
Acquire a lock on a document or directory for an extended amount of time. Locks restrict updates to a document or directory to the user who acquires the lock.
If you lock a directory specifying a depth of "infinity", the directory and all of it children (all documents and directories with a URI started with the locked directory) are locked. You will not be able to add any children to the directory until the lock is released.
When a user locks a URI, it is locked to other users, but not to the user
who locked it. For example, if the user sam locks the URI
/home/sam.xml
by issuing the statement
xdmp.lockAcquire("/home/sam.xml")
,
the user sam
can still issue update commands to the document at that URI, but other users
(for example, the user josh) will get an exception if they try
to update the document.
If you attempt to acquire a lock on a document that already has a lock, the XDMP-LOCKCONFLICT exception is thrown.
If you attempt to update a document that is locked by another user, the XDMP-LOCKED exception is thrown.
Note that the lock described here is a relatively heavy persistent document lock for file system emulation through WebDAV, not a relatively light transaction lock for database consistency.
declareUpdate(); xdmp.lockAcquire("/example.json", "exclusive", "0", "george", "120") => ()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.