fix(cache): 公共 set(key,null) 改用短 null-ttl
set(key,null) 原按数据 TTL(可达 default-ttl-seconds)写入空值标记,使空标记长期 占位;改为与回源空值一致用 null-ttl-seconds(不抖动),空标记宜短。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -339,4 +339,14 @@ class RedisCacheEnhanceTemplateTest {
|
||||
when(valueOps.get("cache:user:1")).thenReturn(null);
|
||||
assertFalse(template.exists("user:1"));
|
||||
}
|
||||
|
||||
// ---- #9: 公共 set(key,null) 用短 null-ttl(与回源空值一致) ----
|
||||
|
||||
@Test
|
||||
void setNullUsesNullTtlNotDataTtl() {
|
||||
props.setJitterRatio(0);
|
||||
template.set("user:1", null, 3600); // 传入数据 TTL,但写空标记应改用短 null-ttl
|
||||
verify(valueOps).set("cache:user:1", CacheConstant.NULL_SENTINEL,
|
||||
props.getNullTtlSeconds(), TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user