|
44 | 44 | *
|
45 | 45 | * @author Christoph Strobl
|
46 | 46 | * @author Mark Paluch
|
| 47 | + * @author Shyngys Sapraliyev |
47 | 48 | */
|
48 | 49 | @MethodSource("testParams")
|
49 | 50 | public class DefaultRedisCacheWriterTests {
|
@@ -104,6 +105,45 @@ void putShouldAddExpiringEntry() {
|
104 | 105 | });
|
105 | 106 | }
|
106 | 107 |
|
| 108 | + @ParameterizedRedisTest // GH-2351 |
| 109 | + void getWithMaxIdleShouldResetEntryTtl() { |
| 110 | + |
| 111 | + Duration maxIdle = Duration.ofSeconds(1); |
| 112 | + |
| 113 | + doWithConnection(connection -> connection.set(binaryCacheKey, "foo".getBytes(), |
| 114 | + Expiration.from(Duration.ofMinutes(1)), SetOption.upsert())); |
| 115 | + |
| 116 | + RedisCacheWriter writer = nonLockingRedisCacheWriter(connectionFactory); |
| 117 | + |
| 118 | + writer.put(CACHE_NAME, binaryCacheKey, binaryCacheValue, Duration.ofSeconds(10), maxIdle); |
| 119 | + |
| 120 | + doWithConnection(connection -> { |
| 121 | + assertThat(writer.get(CACHE_NAME, binaryCacheKey, maxIdle)) |
| 122 | + .isEqualTo(binaryCacheValue); |
| 123 | + assertThat(connection.ttl(binaryCacheKey)) |
| 124 | + .isEqualTo(maxIdle.getSeconds()); |
| 125 | + }); |
| 126 | + } |
| 127 | + |
| 128 | + @ParameterizedRedisTest // GH-2351 |
| 129 | + void getEternalMaxIdleShouldNotExpireEntry() { |
| 130 | + |
| 131 | + Duration maxIdle = Duration.ZERO; |
| 132 | + |
| 133 | + doWithConnection(connection -> connection.set(binaryCacheKey, "foo".getBytes())); |
| 134 | + |
| 135 | + RedisCacheWriter writer = nonLockingRedisCacheWriter(connectionFactory); |
| 136 | + |
| 137 | + writer.put(CACHE_NAME, binaryCacheKey, binaryCacheValue, Duration.ZERO, maxIdle); |
| 138 | + |
| 139 | + doWithConnection(connection -> { |
| 140 | + assertThat(writer.get(CACHE_NAME, binaryCacheKey, maxIdle)) |
| 141 | + .isEqualTo(binaryCacheValue); |
| 142 | + assertThat(connection.ttl(binaryCacheKey)) |
| 143 | + .isEqualTo(-1); |
| 144 | + }); |
| 145 | + } |
| 146 | + |
107 | 147 | @ParameterizedRedisTest // DATAREDIS-481
|
108 | 148 | void putShouldOverwriteExistingEternalEntry() {
|
109 | 149 |
|
|
0 commit comments