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
Refactor, CI & docs #1
Conversation
关于淘汰数据,我想的是使用一个 _expire 队列,然后可以起一个线程遍历队列清理,其他操作像代码里一样从队头开始清理 |
clean 时从队头开始,对于每一个 key 都检查一遍是否超时 | ||
直到现在的 datetime > 队头的到期时间 | ||
但是 set 太多占用空间就会变大 | ||
""" |
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.
关于清理的策略,你这样是很好的,
但是每一次set都会遍历这个队列到适合的位置,会比较浪费性能,
这里我们可以随机选取一定数量的设置有过期时间的key出来,如果过期就delete,
取的这个key的数量我们可以进行优化控制
这样取一个择中的方法,逻辑也更简单,配合我们之后会启一个线程来删除key应该就没有问题了
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.
而且这样的话,我们的存 有过期时间的key 就可以用 集合,增删改查都是 O(1) 了
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.
所以说就是 有过期时间的 key -> 加入集合 -> 每次随机选一定量检查是否过期
这样对吗
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.
对,我感觉这样会好一点
感谢PR,看了一部分代码,给了一点评论,有问题的话,我们可以讨论, 晚上回去在看看,上班摸鱼。。。 |
增加了发版 CI,需要设置 |
commit 较乱,如果要 merge 建议 squash 成一个 commit