Class RedisLockManager
- java.lang.Object
-
- org.nuxeo.ecm.core.redis.contribs.RedisLockManager
-
- All Implemented Interfaces:
LockManager
public class RedisLockManager extends Object implements LockManager
Redis-based lock manager.- Since:
- 6.0
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringprefixprotected StringredisNamespaceprotected StringrepositoryNameprotected StringscriptRemoveShaprotected StringscriptSetSha
-
Constructor Summary
Constructors Constructor Description RedisLockManager(String repositoryName)Creates a lock manager for the given repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LockgetLock(String id)Gets the lock on a document.protected LocklockFromString(String lockString)LockremoveLock(String id, String owner)Removes the lock from a document.LocksetLock(String id, Lock lock)Sets a lock on a document.protected StringstringFromLock(Lock lock)StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.api.lock.LockManager
clearLockManagerCaches, closeLockManager
-
-
-
-
Constructor Detail
-
RedisLockManager
public RedisLockManager(String repositoryName)
Creates a lock manager for the given repository.LockManager.closeLockManager()must be called when done with the lock manager.
-
-
Method Detail
-
getLock
public Lock getLock(String id)
Description copied from interface:LockManagerGets the lock on a document.If the document does not exist,
nullis returned.- Specified by:
getLockin interfaceLockManager- Parameters:
id- the document id- Returns:
- the existing lock, or
nullwhen there is no lock
-
setLock
public Lock setLock(String id, Lock lock)
Description copied from interface:LockManagerSets a lock on a document.If the document is already locked, returns its existing lock status (there is no re-locking,
LockManager.removeLock(java.lang.String, java.lang.String)must be called first).- Specified by:
setLockin interfaceLockManager- Parameters:
id- the document idlock- the lock to set- Returns:
nullif locking succeeded, or the existing lock if locking failed
-
removeLock
public Lock removeLock(String id, String owner)
Description copied from interface:LockManagerRemoves the lock from a document.The previous lock is returned.
If
ownerisnullthen the lock is unconditionally removed.If
owneris notnull, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrueforLock.getFailed().- Specified by:
removeLockin interfaceLockManager- Parameters:
id- the document idowner- the owner to check, ornullfor no check- Returns:
- the previous lock (may be
null), with a failed flag if locking failed
-
-