Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
* @author André Prata
* @author John Blum
* @author ChanYoung Joung
* @author Youngsuk Kim
* @since 2.0
*/
class DefaultRedisCacheWriter implements RedisCacheWriter {
Expand Down Expand Up @@ -212,7 +213,7 @@ public void enable(Consumer<CacheLockingConfiguration> configurationConsumer) {
public CacheLockingConfiguration sleepTime(Duration sleepTime) {

Assert.notNull(sleepTime, "Lock sleep time must not be null");
Assert.isTrue(!sleepTime.isZero() && !sleepTime.isNegative(),
Assert.isTrue(isPositiveDuration(sleepTime),
"Lock sleep time must not be null zero or negative");

this.lockSleepTime = sleepTime;
Expand Down Expand Up @@ -563,7 +564,7 @@ private <T> T executeLockFree(Function<RedisConnection, T> callback) {
* @return {@literal true} if {@link RedisCacheWriter} uses locks.
*/
private boolean isLockingCacheWriter() {
return !this.sleepTime.isZero() && !this.sleepTime.isNegative();
return isPositiveDuration(this.sleepTime);
}

private void checkAndPotentiallyWaitUntilUnlocked(String name, RedisConnection connection) {
Expand Down Expand Up @@ -601,6 +602,10 @@ private static boolean shouldExpireWithin(@Nullable Duration ttl) {
return ttl != null && !ttl.isZero() && !ttl.isNegative();
}

private static boolean isPositiveDuration(Duration duration) {
return !duration.isZero() && !duration.isNegative();
}

/**
* Interface for asynchronous cache retrieval.
*
Expand Down