alibaba / alibaba/jetcache

缓存 Null Value 时,是否默认添加 TTL

Open
#520 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

老师,您好!这里有个问题想向您请教!

当缓存 `null value` 后,如果不主动失效该缓存,且未设置 `ttl`,那么该缓存的 `value` 将会一直是 `null`。
针对该问题,请问是否有比较优雅的解决方案?

这里有一个思路,烦请您评估一下是否可行,谢谢!

如下:

如果创建缓存的时候,`value` 值为 `null`,且 `cacheNullValue` 等于 `true`,如果缓存没有设置 `ttl`,那该缓存对应的 `value` 就会一直都是 `null`。那么能不能在缓存 `null value` 时,默认添加 `ttl`,比如 `300s`,这样的话就可以在 `300s` 后重新去 `db` 获取最新数据。

如果可以在 `@Cache` 注解增加对应的配置,那就更完美了。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the cache-null handling path and the @Cache annotation configuration mentioned in the issue. Determine whether null entries without an explicit TTL should receive a default 300-second expiry and how that setting should be exposed. Done means the behavior and configuration are defined and covered by tests, but no test or source file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.