Class RedisLockProvider
- java.lang.Object
-
- net.javacrumbs.shedlock.provider.redis.spring.RedisLockProvider
-
- All Implemented Interfaces:
LockProvider
public class RedisLockProvider extends Object implements LockProvider
Uses Redis's `SET resource-name anystring NX PX max-lock-ms-time` as locking mechanism. See https://redis.io/commands/set
-
-
Constructor Summary
Constructors Constructor Description RedisLockProvider(@NotNull org.springframework.data.redis.connection.RedisConnectionFactory redisConn)RedisLockProvider(@NotNull org.springframework.data.redis.connection.RedisConnectionFactory redisConn, @NotNull String environment)Creates RedisLockProvider
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Optional<SimpleLock>lock(@NotNull LockConfiguration lockConfiguration)
-
-
-
Constructor Detail
-
RedisLockProvider
public RedisLockProvider(@NotNull @NotNull org.springframework.data.redis.connection.RedisConnectionFactory redisConn)
-
RedisLockProvider
public RedisLockProvider(@NotNull @NotNull org.springframework.data.redis.connection.RedisConnectionFactory redisConn, @NotNull @NotNull String environment)Creates RedisLockProvider- Parameters:
redisConn- RedisConnectionFactoryenvironment- environment is part of the key and thus makes sure there is not key conflict between multiple ShedLock instances running on the same Redis
-
-
Method Detail
-
lock
@NotNull public @NotNull Optional<SimpleLock> lock(@NotNull @NotNull LockConfiguration lockConfiguration)
- Specified by:
lockin interfaceLockProvider
-
-