Skip to content

Commit a00fd48

Browse files
committed
fix: duplicated conditional TTL evaluation
Signed-off-by: Hyun Jong Park <[email protected]>
1 parent 19573e2 commit a00fd48

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/springframework/data/redis/cache/DefaultRedisCacheWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,11 @@ public byte[] get(String name, byte[] key, Supplier<byte[]> valueLoader, @Nullab
270270
Assert.notNull(key, "Key must not be null");
271271

272272
boolean withTtl = shouldExpireWithin(ttl);
273+
Duration ttlForGet = (timeToIdleEnabled && withTtl ? ttl : null);
273274

274275
// double-checked locking optimization
275276
if (isLockingCacheWriter()) {
276-
byte[] bytes = get(name, key, timeToIdleEnabled && withTtl ? ttl : null);
277+
byte[] bytes = get(name, key, ttlForGet);
277278
if (bytes != null) {
278279
return bytes;
279280
}
@@ -287,7 +288,7 @@ public byte[] get(String name, byte[] key, Supplier<byte[]> valueLoader, @Nullab
287288

288289
try {
289290

290-
byte[] result = doGet(connection, name, key, timeToIdleEnabled && withTtl ? ttl : null);
291+
byte[] result = doGet(connection, name, key, ttlForGet);
291292

292293
if (result != null) {
293294
return result;

0 commit comments

Comments
 (0)