DATAREDIS-1106 - Remove expiration phantom key on delete via KeyValueAdapter.

Original pull request: #521.
This commit is contained in:
Christoph Strobl
2020-04-06 12:57:02 +02:00
committed by Mark Paluch
parent 86b3f45783
commit cca1f7a8cf
5 changed files with 65 additions and 5 deletions

View File

@@ -297,6 +297,24 @@ public class RedisKeyValueAdapterTests {
assertThat(template.opsForSet().members("persons:firstname:rand")).doesNotContain("1");
}
@Test // DATAREDIS-1106
public void deleteRemovesExpireHelperStructures() {
WithExpiration source = new WithExpiration();
source.id = "1";
source.value = "vale";
adapter.put("1", source, "withexpiration");
assertThat(template.hasKey("withexpiration:1")).isTrue();
assertThat(template.hasKey("withexpiration:1:phantom")).isTrue();
adapter.delete("1", "withexpiration", WithExpiration.class);
assertThat(template.hasKey("withexpiration:1")).isFalse();
assertThat(template.hasKey("withexpiration:1:phantom")).isFalse();
}
@Test // DATAREDIS-425
public void keyExpiredEventShouldRemoveHelperStructures() throws Exception {
@@ -765,4 +783,12 @@ public class RedisKeyValueAdapterTests {
String name;
}
@KeySpace("withexpiration")
@RedisHash(timeToLive = 30)
static class WithExpiration {
@Id String id;
String value;
}
}