I am trying to implement shedlock in a Java Spring Boot application using redis. In every resource I search for it is mentioned that shedlock is compatible with Redis, however I couldn't find how to implement the same. Could someone please help me with the detailed steps?
Note: I am only using the redis as database and no other database is linked with my app. Also in my application, I am using jedis pool for accessing the redis instances.
I have the below queries in implementing the same.
- Since Shedlock wants to have the below table created, how can we create the same in redis cache? (How primary key and all can be defined here)?
CREATE TABLE shedlock(
name VARCHAR(64) NOT NULL,
lock_until TIMESTAMP NOT NULL,
locked_at TIMESTAMP NOT NULL,
locked_by VARCHAR(255) NOT NULL,
PRIMARY KEY (name)
);
- How the Lock provider Bean should be configured? I could see examples for other DBs, but none using redis instance. How using Jedis pool, once can configure the LockProvider Bean?
@Configuration
public class ShedLockConfig {
@Bean
public LockProvider lockProvider(DataSource dataSource) {
return new JdbcTemplateLockProvider(dataSource);
}
}
Thanks