Loading TOC...

xdmp.lockAcquire

xdmp.lockAcquire(
   $uri as String,
   [$scope as String?],
   [$depth as String?],
   [$owner as Sequence],
   [$timeout as String?]
) as null

Summary

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.

Parameters
$uri The URI of the document or directory to be locked.
$scope The lock scope ("exclusive" or "shared"). The default is "exclusive".
$depth The lock depth ("0" or "infinity"). "0" locks the URI only, and "infinity" locks the URI (the document or directory) and all of its children. The default is "0".
$owner Alternate description of the lock owner. If not specified or if specified as the empty sequence ( () ), then the owner is the user name of the user requesting the lock.
$timeout Requested lock timeout in seconds. If not specified or if specified as the empty sequence ( () ) or if specified as 0, then the timeout is infinite.

Usage Notes

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:lock-acquire("/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.

Example

declareUpdate();
xdmp.lockAcquire("/example.json",
   "exclusive", "0", "george", "120")
=> ()

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy