Class RedisLockProvider

java.lang.Object
net.javacrumbs.shedlock.provider.redis.spring.RedisLockProvider
All Implemented Interfaces:
net.javacrumbs.shedlock.core.ExtensibleLockProvider, net.javacrumbs.shedlock.core.LockProvider

public class RedisLockProvider extends Object implements net.javacrumbs.shedlock.core.ExtensibleLockProvider
Uses Redis's `SET resource-name anystring NX PX max-lock-ms-time` as locking mechanism. See https://redis.io/commands/set
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RedisLockProvider(org.springframework.data.redis.connection.RedisConnectionFactory redisConn)
     
    RedisLockProvider(org.springframework.data.redis.connection.RedisConnectionFactory redisConn, String environment)
    Creates RedisLockProvider
    RedisLockProvider(org.springframework.data.redis.connection.RedisConnectionFactory redisConn, String environment, String keyPrefix)
    Creates RedisLockProvider
    RedisLockProvider(org.springframework.data.redis.core.StringRedisTemplate redisTemplate, String environment, String keyPrefix)
    Create RedisLockProvider
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<net.javacrumbs.shedlock.core.SimpleLock>
    lock(net.javacrumbs.shedlock.core.LockConfiguration lockConfiguration)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RedisLockProvider

      public RedisLockProvider(org.springframework.data.redis.connection.RedisConnectionFactory redisConn)
    • RedisLockProvider

      public RedisLockProvider(org.springframework.data.redis.connection.RedisConnectionFactory redisConn, String environment)
      Creates RedisLockProvider
      Parameters:
      redisConn - RedisConnectionFactory
      environment - environment is part of the key and thus makes sure there is not key conflict between multiple ShedLock instances running on the same Redis
    • RedisLockProvider

      public RedisLockProvider(org.springframework.data.redis.connection.RedisConnectionFactory redisConn, String environment, String keyPrefix)
      Creates RedisLockProvider
      Parameters:
      redisConn - RedisConnectionFactory
      environment - environment is part of the key and thus makes sure there is not key conflict between multiple ShedLock instances running on the same Redis
      keyPrefix - prefix of the key in Redis.
    • RedisLockProvider

      public RedisLockProvider(org.springframework.data.redis.core.StringRedisTemplate redisTemplate, String environment, String keyPrefix)
      Create RedisLockProvider
      Parameters:
      redisTemplate - StringRedisTemplate
      environment - environment is part of the key and thus makes sure there is not key conflict between multiple ShedLock instances running on the same Redis
      keyPrefix - prefix of the key in Redis.
  • Method Details

    • lock

      public Optional<net.javacrumbs.shedlock.core.SimpleLock> lock(net.javacrumbs.shedlock.core.LockConfiguration lockConfiguration)
      Specified by:
      lock in interface net.javacrumbs.shedlock.core.LockProvider