Skip to content

Commit 9065159

Browse files
authored
Fixing TTL logic on getValueExpiryRaw
1 parent 53b012c commit 9065159

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/main/java/picoded/dstack/redisson/Redisson_KeyValueMap.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,19 @@ public MutablePair<String, Long> getValueExpiryRaw(String key, long now) {
270270
}
271271
String value = entry.getValue();
272272

273-
Long expireObj = backendMap().remainTimeToLive(key) + System.currentTimeMillis();
274-
// Note: 0 = no timestamp, hence valid value
275-
long expiry = expireObj.longValue();
276-
return new MutablePair<String, Long>(value, expiry);
273+
// Get the raw TTL
274+
long rawTTL = backendMap().remainTimeToLive(key);
275+
if( rawTTL <= -2 ) {
276+
// value has expired
277+
return null;
278+
} else if( rawTTL <= -1 ) {
279+
// has no expiry
280+
// Note: 0 = no timestamp, hence valid value
281+
return new MutablePair<String, Long>(value, 0);
282+
}
283+
284+
// Return with expiry value
285+
return new MutablePair<String, Long>(value, rawTTL + System.currentTimeMillis());
277286
}
278287
return null;
279288
}

0 commit comments

Comments
 (0)