SimpleRedisLock extends AbstractSimpleLock { @Override protected boolean refresh(final String key, final String storeId, final String token, final long expiration) { final var singletonKeyList = Collections.singletonList(storeId + ":" + key); final var refreshed = stringRedisTemplate.execute(lockRefreshScript, singletonKeyList, token, String.valueOf(expiration)); if (refreshed) { log.debug("Refresh script updated the expiration for key {} with token {} in store {} to {}", key, token, storeId, expiration); } else { log.debug("Refresh script failed to update expiration for key {} with token {} in store {} with expiration: {}", key, token, storeId, expiration); } return refreshed; } SimpleRedisLock(final Supplier<String> tokenSupplier, final StringRedisTemplate stringRedisTemplate);   }
@Test public void shouldNotRefreshBecauseKeyExpired() { assertThat(lock.refresh(Collections.singletonList("1"), "locks", "abc", 1000)).isFalse(); assertThat(redisTemplate.keys("*")).isNullOrEmpty(); }