-
Notifications
You must be signed in to change notification settings - Fork 15
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
feature add lru cache evict #30
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
==========================================
- Coverage 97.94% 96.92% -1.02%
==========================================
Files 4 7 +3
Lines 632 845 +213
==========================================
+ Hits 619 819 +200
- Misses 9 20 +11
- Partials 4 6 +2 ☔ View full report in Codecov by Sentry. |
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.
不需要做这种抽象,因为之前在别的实现里面,已经有了一个优先级的淘汰的实现了。
这个抽象的意义不是很大,核心就在于 EvictStrategy 太多方法了,没有谁愿意提供新的实现。
所以直接整合为一个 lru cache 就可以。
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.
直接整个实现就叫做 LRU,然后就只支持 LRU。LRU 和别的不太容易混合在一起,因为 LRU 需要考虑根据更新访问时间来调整整个结构。
其次,通过在 element 中维护 list,能够依次遍历链表,使用 pushBackList 在链表尾部添加元素或pushFrontList头部添加元素,这样的设计使得链表的操作更加方便和高效。
|
这个也没必要,因为正常我们 list 操作,都是在对应的 Add 或者 Remove 里面,沿着 Element 追溯或者回溯。 所以这里不要反向依赖 list。 |
我草,GO build 都失败了。有 Data race |
其余你也要修复了。 |
No description provided.