-
Notifications
You must be signed in to change notification settings - Fork 220
refactor: 媒体缓存改用 LRU #3300
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
base: next
Are you sure you want to change the base?
refactor: 媒体缓存改用 LRU #3300
Conversation
|
你好 @Alexzjt,非常感谢你的贡献. Hello, @Alexzjt, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes. |
Summary of ChangesHello @Alexzjt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the media cache used in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
本次 PR 将媒体缓存从 Map 切换到了 LRU 缓存策略,这是一个很好的重构。使用 LRU 缓存可以限制缓存大小,避免了 Map 可能导致的无限增长和潜在的内存泄漏问题。代码改动清晰,符合预期。我有一个关于魔法数字的小建议,以提高代码的可读性和可维护性。
|
|
||
| export abstract class BaseRenderer { | ||
| static mediaCache = new Map<string, HTMLElement | null>(); | ||
| static mediaCache: flruCache<HTMLElement | null> = flru(200); |
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3300 +/- ##
==========================================
+ Coverage 75.77% 78.86% +3.09%
==========================================
Files 257 223 -34
Lines 11994 12271 +277
Branches 2464 2760 +296
==========================================
+ Hits 9088 9678 +590
+ Misses 1398 928 -470
- Partials 1508 1665 +157 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Size Change: +139 B (+0.02%) Total Size: 725 kB
ℹ️ View Unchanged
|
👀 PR includes
✨ Feature
🎨 Enhance
🐛 Bugfix
🔧 Chore
📝 Description
🖼️ Screenshot
🔗 Related issue link
🔍 Self-Check before the merge