我如何告诉 Spring Cache 缓存 @Cacheable 注释中的异常?
How do I tell Spring Cache to cache the exceptions in @Cacheable annotation?
我需要 3 个独立的缓存:
- 响应一些数据
- 空
- 异常
我已经定义了两个缓存
@Caching(cacheable = {
@Cacheable(value = "SomeCache", key = "#a1", unless = "#result == null"),
@Cacheable(value = "SomeNullCache", key = "#a1", unless = "#result != null")})
所以,我必须实现最后一个案例。
JSR-107 提供了带有 exceptionCacheName 属性的 @CacheResult 注释,但是我如何使用 Spring 缓存来做到这一点?我不想结合 JSR-107 和 Spring 缓存。
缓存抽象不支持注释方法抛出的缓存异常。我觉得你的设置很奇怪。为什么要为空值和非空值使用两个不同的区域?
如果需要这样的设置,请使用标准注释。
I don't want to combine JSR-107 and Spring Cache.
id 生成不同(为了符合规范并保持向后兼容性),我不建议这样使用。至少不在同一个地区。
我需要 3 个独立的缓存:
- 响应一些数据
- 空
- 异常
我已经定义了两个缓存
@Caching(cacheable = {
@Cacheable(value = "SomeCache", key = "#a1", unless = "#result == null"),
@Cacheable(value = "SomeNullCache", key = "#a1", unless = "#result != null")})
所以,我必须实现最后一个案例。
JSR-107 提供了带有 exceptionCacheName 属性的 @CacheResult 注释,但是我如何使用 Spring 缓存来做到这一点?我不想结合 JSR-107 和 Spring 缓存。
缓存抽象不支持注释方法抛出的缓存异常。我觉得你的设置很奇怪。为什么要为空值和非空值使用两个不同的区域?
如果需要这样的设置,请使用标准注释。
I don't want to combine JSR-107 and Spring Cache.
id 生成不同(为了符合规范并保持向后兼容性),我不建议这样使用。至少不在同一个地区。