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 String
prefix
protected String
redisNamespace
protected String
repositoryName
protected String
scriptRemoveSha
protected String
scriptSetSha
-
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 Lock
getLock(String id)
Gets the lock on a document.protected Lock
lockFromString(String lockString)
Lock
removeLock(String id, String owner)
Removes the lock from a document.Lock
setLock(String id, Lock lock)
Sets a lock on a document.protected String
stringFromLock(Lock lock)
String
toString()
-
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:LockManager
Gets the lock on a document.If the document does not exist,
null
is returned.- Specified by:
getLock
in interfaceLockManager
- Parameters:
id
- the document id- Returns:
- the existing lock, or
null
when there is no lock
-
setLock
public Lock setLock(String id, Lock lock)
Description copied from interface:LockManager
Sets 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:
setLock
in interfaceLockManager
- Parameters:
id
- the document idlock
- the lock to set- Returns:
null
if locking succeeded, or the existing lock if locking failed
-
removeLock
public Lock removeLock(String id, String owner)
Description copied from interface:LockManager
Removes the lock from a document.The previous lock is returned.
If
owner
isnull
then the lock is unconditionally removed.If
owner
is notnull
, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrue
forLock.getFailed()
.- Specified by:
removeLock
in interfaceLockManager
- Parameters:
id
- the document idowner
- the owner to check, ornull
for no check- Returns:
- the previous lock (may be
null
), with a failed flag if locking failed
-
-