Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2203

Shedlock with Spring and Redis

$
0
0

I'm using Shedlock with Spring Boot and Redis as Lock Provider.

Everything seems to work fine. But when I manually go to the Redis during the execution of the task I see no specific KEY for the lock.

On the Redis CLI I do KEYS * to get all keys.

Is this expected or do I miss any configuration?

@Beanpublic LockProvider lockProvider() {   return new JedisLockProvider(redisPoolPrimary.getPool(), RedisPoolPrimary.ENV_ID);}
@Component@Slf4jpublic class RedisPoolPrimary {    public static final String ENV_ID = "MyAppId";    private JedisPool pool;    public RedisPoolPrimary(@Value("${spring.redis.url}") String redisCloudUrl,                            @Value("${meetical.redis.jedis.JEDIS_POOL_MAX_TOTAL}") int jedisPoolMaxTotal,                            @Value("${meetical.redis.jedis.JEDIS_POOL_MAX}") int jedisPoolMax,                            @Value("${meetical.redis.jedis.JEDIS_POOLMAX_IDLE}") int jedisPoolMaxIdle    ) {        URI redisUrl = URI.create(redisCloudUrl);        JedisPoolConfig poolConfig = new JedisPoolConfig();        poolConfig.setMaxTotal(jedisPoolMaxTotal);        poolConfig.setMinIdle(jedisPoolMax);        poolConfig.setMaxIdle(jedisPoolMaxIdle);        pool = new JedisPool(poolConfig, redisUrl);    }    public JedisPool getPool() {        return pool;    }}
@Scheduled(cron = "${cache.scheduler.cron.expression}")@SchedulerLock(name = "refreshUserCachesLock", lockAtLeastForString = FIVE_MINUTES, lockAtMostForString = SIXTY_MINUTES)public void refreshCacheOfAllInstances() {   // should be only run once every x hours for all spring boot app nodes   // however during execution of the task no KEY seems to be in Redis - does the lock mechanism work?}

Dependencies used

<dependency><groupId>net.javacrumbs.shedlock</groupId><artifactId>shedlock-spring</artifactId><version>4.12.0</version></dependency><dependency><groupId>net.javacrumbs.shedlock</groupId><artifactId>shedlock-provider-redis-jedis</artifactId><version>4.12.0</version></dependency>

Viewing all articles
Browse latest Browse all 2203

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>