Class RedisLockManager

  • All Implemented Interfaces:
    LockManager

    public class RedisLockManager
    extends Object
    implements LockManager
    Redis-based lock manager.
    Since:
    6.0
    • Field Detail

      • redisNamespace

        protected final String redisNamespace
      • repositoryName

        protected final String repositoryName
      • prefix

        protected String prefix
      • scriptSetSha

        protected String scriptSetSha
      • scriptRemoveSha

        protected String scriptRemoveSha
    • 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

      • stringFromLock

        protected String stringFromLock​(Lock lock)
      • lockFromString

        protected Lock lockFromString​(String lockString)
      • 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 interface LockManager
        Parameters:
        id - the document id
        Returns:
        the existing lock, or null when there is no lock
      • 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 is null then the lock is unconditionally removed.

        If owner is not null, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will return true for Lock.getFailed().

        Specified by:
        removeLock in interface LockManager
        Parameters:
        id - the document id
        owner - the owner to check, or null for no check
        Returns:
        the previous lock (may be null), with a failed flag if locking failed