This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Acquire advisory lock on persistence service mutex


TF = acquire(lk,timeout)



TF = acquire(lk,timeout) acquires an advisory lock and returns a logical 1 (true) if the lock was successful, and a logical 0 (false) otherwise. If the lock is unavailable, acquire will continue trying to acquire it for timeout seconds.


collapse all

First, create a persistence service controller object and use that object to start the persistence service.

ctrl = mps.cache.control('myRedisConnection','Redis','Port',4519);

Use the connection name to create a persistence service mutex.

lk = mps.sync.lock('myDbLock','Connection','myRedisConnection')

Try to acquire advisory lock. If lock is unavailable, retry acquiring for 20 seconds.

acquire(lk, 20);
TF =



Input Arguments

collapse all

A persistence service specific mutex object. If you use Redis™ as your persistence provider, lk will be a mps.sync.TimedRedisMutex object. If you use a MATLAB® as your persistence provider, lk will be a mps.sync.TimedMATFileMutex object.

Output Arguments

collapse all

TF has a logical 1 (true) if acquiring the advisory lock was successful, and a logical 0 (false) otherwise.

Introduced in R2018b