fix: renew route lrucache when the routes change#8119
Conversation
|
@kingluo pls rebase your branch |
f9357b6 to
82620f7
Compare
| core.log.info("use ai plane to match route") | ||
| router.router_http.match = ai_match | ||
|
|
||
| local count = #routes + 3000 |
There was a problem hiding this comment.
I am not familiar with the route cache design, so the questions below need to be answered by someone who is familiar with it. CC @membphis @tzssangglass
- do we need to clean the cache when we switch 'cache' to 'no cache'?
- is it desirable to recreate cache once the router is rebuilt (a new route is added)?
There was a problem hiding this comment.
If it is desirable, we need to switch the cache lookup way from key + ver to key as each ver has its own cache now. Also, we may not need to init the cache as it may be created in the first router building.
There was a problem hiding this comment.
2. is it desirable to recreate cache once the router is rebuilt (a new route is added)?
no, if the router is rebuilt, the cache version(router.router_http.user_routes.conf_version) would be changed, so a new request comes in and generates the cache key as old would execute origin router_match and generates new matched_route, and cache new matched_route.
There was a problem hiding this comment.
do we need to clean the cache when we switch 'cache' to 'no cache'?
I don't think it's needed because 'cache' to 'no cache' means router.router_http.user_routes.conf_version has changed, refer to the explanation above.
Do we need to recreate the lrucache when switching 'cache' to 'no cache'? @membphis
There was a problem hiding this comment.
for the better performance and logic simple, I think we should renew the lrucache and ignore router.router_http.user_routes.conf_version, which is more simpler to read and understanding
There was a problem hiding this comment.
I don't think it's needed because 'cache' to 'no cache' means router.router_http.user_routes.conf_version has changed, refer to the explanation above.
So it is acceptable to keep the unused cache when we move to 'no cache'?
BTW, look like we can remove the init in
Line 48 in 3887162
There was a problem hiding this comment.
So it is acceptable to keep the unused cache when we move to 'no cache'?
I think it's needed.
f9357b6 to
6b0009f
Compare
Description
Fixes # (issue)
Checklist