Move expires check to dedicated method.
Introduce helper method to unify expiry check and simplify control flow. Original Pull Request: #1961
This commit is contained in:
@@ -706,10 +706,10 @@ public class RedisKeyValueAdapterTests {
|
||||
assertThat(template.hasKey("persons:1:phantom")).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1955
|
||||
@Test // GH-1955
|
||||
void phantomKeyIsDeletedWhenPutWithNegativeTimeToLiveAndOldEntryTimeToLiveWasPositiveAndWhenShadowCopyIsTurnedOn() {
|
||||
|
||||
ExpiringPerson rand = new ExpiringPerson();
|
||||
rand.id = "1";
|
||||
rand.ttl = 3000L;
|
||||
|
||||
adapter.put("1", rand, "persons");
|
||||
@@ -723,21 +723,21 @@ public class RedisKeyValueAdapterTests {
|
||||
assertThat(template.hasKey("persons:1:phantom")).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1955
|
||||
@Test // GH-1955
|
||||
void updateWithRefreshTtlAndWithoutPositiveTtlShouldDeletePhantomKey() {
|
||||
|
||||
ExpiringPerson person = new ExpiringPerson();
|
||||
person.id = "1";
|
||||
person.ttl = 100L;
|
||||
|
||||
adapter.put("1", person, "persons");
|
||||
|
||||
assertThat(template.getExpire("persons:1:phantom")).isPositive();
|
||||
|
||||
PartialUpdate<ExpiringPerson> update = new PartialUpdate<>("1", ExpiringPerson.class) //
|
||||
.refreshTtl(true);
|
||||
.set("ttl", -1L).refreshTtl(true);
|
||||
|
||||
adapter.update(update);
|
||||
|
||||
assertThat(template.getExpire("persons:1")).isNotPositive();
|
||||
assertThat(template.hasKey("persons:1:phantom")).isFalse();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user