alibaba / alibaba/jetcache

缓存自动刷新在computeIfAbsent调用时不触发

Open
#338 2 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

版本2.5.13
使用@CreateCache创建缓存,设置了定时刷新策略和loader,在使用get获取数据时会触发自动刷新任务,在使用computeIfAbsent数据后不会触发自动刷新。

看了一下源码刷新任务是在RefreshCache的GET、GETALL中加入的,这是个代理对象,未覆盖computeIfAbsent,这样在调用到实际缓存的computeIfAbsent时,虽然内部有对具体缓存的GET,但不会触发RefreshCache的GET,因此不会添加刷新任务,调试过调用computeIfAbsent全程不会走addOrUpdateRefreshTask不会产生刷新任务。
computeIfAbsent也相当于一种get,在用Cache对象的时使用computeIfAbsent获取数据情况会比较多,是不是也应该触发刷新?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the RefreshCache proxy and compare its GET and GETALL handling with the underlying computeIfAbsent path. Trace whether addOrUpdateRefreshTask is reached, then inspect existing cache refresh tests or add coverage for computeIfAbsent so its refresh behavior matches get. Done means the scheduled refresh task is created when computeIfAbsent retrieves data.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.