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

Refactor, CI & docs #1

Merged
merged 15 commits into from Jul 17, 2022
Merged

Refactor, CI & docs #1

merged 15 commits into from Jul 17, 2022

Conversation

YuzhenQin
Copy link
Contributor

@YuzhenQin YuzhenQin commented Jul 12, 2022

commit 较乱,如果要 merge 建议 squash 成一个 commit

  • 修复 README 内的 typo
  • 增加 README Lint CI
  • 修改了 incr 和 decr,共用一个 _incr
  • 修改 keys 函数的逻辑
  • 增加 clean 和 clean_force 函数
  • CodeQL 代码扫描
  • README 双语 & badge
  • 增加发版 CI
  • 增加代码 Lint CI
  • 文档框架

@YuzhenQin YuzhenQin marked this pull request as draft July 12, 2022 12:14
@YuzhenQin YuzhenQin changed the title fix typo, lint, refactor and add clean function refactor & ci Jul 12, 2022
@YuzhenQin YuzhenQin marked this pull request as ready for review July 12, 2022 12:56
@Zombie123456 Zombie123456 self-requested a review July 12, 2022 13:10
@YuzhenQin
Copy link
Contributor Author

关于淘汰数据,我想的是使用一个 _expire 队列,然后可以起一个线程遍历队列清理,其他操作像代码里一样从队头开始清理

@YuzhenQin YuzhenQin marked this pull request as draft July 13, 2022 02:24
pydis/core.py Outdated Show resolved Hide resolved
pydis/core.py Outdated Show resolved Hide resolved
clean 时从队头开始,对于每一个 key 都检查一遍是否超时
直到现在的 datetime > 队头的到期时间
但是 set 太多占用空间就会变大
"""
Copy link
Owner

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应该就没有问题了

Copy link
Owner

Choose a reason for hiding this comment

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

而且这样的话,我们的存 有过期时间的key 就可以用 集合,增删改查都是 O(1) 了

Copy link
Contributor Author

@YuzhenQin YuzhenQin Jul 13, 2022

Choose a reason for hiding this comment

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

所以说就是 有过期时间的 key -> 加入集合 -> 每次随机选一定量检查是否过期 这样对吗

Copy link
Owner

Choose a reason for hiding this comment

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

对,我感觉这样会好一点

pydis/core.py Outdated Show resolved Hide resolved
@Zombie123456
Copy link
Owner

感谢PR,看了一部分代码,给了一点评论,有问题的话,我们可以讨论, 晚上回去在看看,上班摸鱼。。。

@YuzhenQin
Copy link
Contributor Author

YuzhenQin commented Jul 13, 2022

增加了发版 CI,需要设置 PYPI_API_TOKEN secret,在发布 release 的时候会自动把构建的 tar.gz 和 wheel 添加到 release 的 assets 里并上传到 PyPI

@YuzhenQin YuzhenQin changed the title refactor & ci Refactor, CI & docs Jul 13, 2022
@YuzhenQin YuzhenQin marked this pull request as ready for review July 14, 2022 11:09
@Zombie123456 Zombie123456 merged commit 39431fa into Zombie123456:master Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants