-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat(cache): bring up lfu #3901
Conversation
module.exports = ctx => { | ||
let cache = {}; | ||
const cache = new LRU(50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have run some test by using Object.keys(cache).length
to know the size of cache for some popular themes:
Theme | Current cache size |
---|---|
hexo-theme-light | 1 |
hexo-theme-tranquilpeak | 3 |
hexo-theme-landscape | 4 |
hexo-theme-cake | 17 |
hexo-theme-next | 18 |
hexo-theme-suka | 18 |
hexo-theme-icarus | 98 |
Those data are from one-language site. Multi-language site could have larger size of cache.
Maybe 50 is still to large. We could use 15 or 20 (I prefer 20).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is best to be exposed to the outside for configuration, If some theme has larger cache length, it can adjust it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of users have no idea about the cache size of their themes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of users have no idea about the cache size of their themes.
But as a theme developer. If he knew clearly that he needed 50+, how to achieve it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiangtj In fact he/she doesn't. It is better to cache as less as possible because larger size of cache means higher memory usage. It is not a wise idea to cache everything in the fragment_cache
. That's how LFU works, by only caching the most usefuls.
What does it do?
This PR is a part of proposal #3897, bring up LFU cache for
fragment_cache()
.How to test
Screenshots
Pull request tasks