Skip to content
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

feat: 基于优先级淘汰的本地缓存设计与实现 #19

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

uzziahlin
Copy link
Collaborator

优先级队列实现,以及基于优先级淘汰的本地缓存设计与实现

Copy link
Contributor

@flycash flycash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ekit 的 Queue 可能有比较多问题,不一定能直接用,但是应该尽可能适配过去,省得维护两个优先级队列要崩溃。

memory/priority/cache.go Outdated Show resolved Hide resolved
memory/priority/cache.go Outdated Show resolved Hide resolved
memory/priority/cache.go Outdated Show resolved Hide resolved
memory/priority/cache.go Outdated Show resolved Hide resolved
@flycash
Copy link
Contributor

flycash commented Sep 24, 2023

要现在 ekit 里面暴露了 Internal 里面的优先级队列,然后你这里直接使用。如果每一个地方都维护一个优先级队列,要崩溃。

@flycash
Copy link
Contributor

flycash commented Oct 5, 2023

先等我解决了另外一个合并请求来,那边也有优先级队列的问题。不过那边的解决方案有点不太一样。后面找你讨论。

@uzziahlin
Copy link
Collaborator Author

先等我解决了另外一个合并请求来,那边也有优先级队列的问题。不过那边的解决方案有点不太一样。后面找你讨论。

好的

@flycash
Copy link
Contributor

flycash commented Oct 13, 2023

合并最新代码,你可以先看看红黑树那边的基本思路。核心还是这个优先级队列不好维护。

@uzziahlin
Copy link
Collaborator Author

合并最新代码,你可以先看看红黑树那边的基本思路。核心还是这个优先级队列不好维护。

我大概看了一下,我的理解是,目前还是认为用户不会修改数据的优先级,也就是就算数据的优先级改了也不会重新进行堆化,然后每次删除进行标记删除,等到淘汰的时候迭代删除空节点。这样理解有无问题?

@flycash
Copy link
Contributor

flycash commented Oct 28, 2023

合并最新代码,你可以先看看红黑树那边的基本思路。核心还是这个优先级队列不好维护。

我大概看了一下,我的理解是,目前还是认为用户不会修改数据的优先级,也就是就算数据的优先级改了也不会重新进行堆化,然后每次删除进行标记删除,等到淘汰的时候迭代删除空节点。这样理解有无问题?

是的,就是这个原则, 你可以在注释里面标注一下,这里暂时不支持调整优先级。

@flycash
Copy link
Contributor

flycash commented Oct 28, 2023

大哥你的各种 CI 都崩溃了!

Copy link

codecov bot commented Nov 5, 2023

Codecov Report

Merging #19 (d7bae5d) into main (10ff4bc) will decrease coverage by 6.00%.
Report is 1 commits behind head on main.
The diff coverage is 75.48%.

@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
- Coverage   98.37%   92.38%   -6.00%     
==========================================
  Files           4        5       +1     
  Lines         615      840     +225     
==========================================
+ Hits          605      776     +171     
- Misses          7       58      +51     
- Partials        3        6       +3     
Files Coverage Δ
memory/priority/cache.go 75.48% <75.48%> (ø)

... and 2 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants