-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
进行数据更新时,使高速缓存失效,以便重新执行规则检查 #606
Conversation
WalkthroughThe pull request introduces updates across several classes in the application. Notable changes include the addition of a Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (8)
src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHGeneralController.java (3)
24-25
: LGTM: New field declaration is correct. Consider minor formatting adjustment.The
moduleMatchCache
field is correctly declared as private and uses the@Autowired
annotation for dependency injection. The naming convention is appropriate.Consider moving the field declaration to a single line for consistency with other field declarations in the class:
- @Autowired - private ModuleMatchCache moduleMatchCache; + @Autowired private ModuleMatchCache moduleMatchCache;
65-65
: LGTM: Cache invalidation is correctly implemented. Consider adding error handling.The
moduleMatchCache.invalidateAll()
call is appropriately placed at the end of thehandleReloading
method, ensuring that the cache is invalidated after all reload operations are complete.Consider adding error handling to ensure that the API response is not affected if the cache invalidation fails:
- moduleMatchCache.invalidateAll(); + try { + moduleMatchCache.invalidateAll(); + } catch (Exception e) { + // Log the error, but don't let it affect the API response + log.error("Failed to invalidate module match cache", e); + }This change will improve the robustness of the API endpoint.
Line range hint
1-85
: Overall, the changes effectively implement cache invalidation as intended.The introduction of the
ModuleMatchCache
and its invalidation in thehandleReloading
method aligns well with the PR objective. This ensures that the cache is cleared after configuration reloads, leading to fresh rule checks.Consider adding a brief comment above the
moduleMatchCache.invalidateAll();
line to explain its purpose:+ // Invalidate the module match cache to ensure fresh rule checks after reload moduleMatchCache.invalidateAll();
This will help future developers understand the reasoning behind this operation.
src/main/java/com/ghostchu/peerbanhelper/btn/ability/BtnAbilityRules.java (1)
105-105
: Approve the cache invalidation with a suggestion for optimization.The addition of
btnNetwork.getModuleMatchCache().invalidateAll();
is a good practice to ensure consistency between the newly loaded rules and the cache. This change prevents potential issues that could arise from using outdated cached data with new rules.However, consider optimizing this operation by only invalidating the cache when the rules have actually changed. This could be achieved by comparing the new version with the old version before invalidating the cache.
Consider modifying the code as follows to optimize cache invalidation:
BtnRule btr = JsonUtil.getGson().fromJson(r.body(), BtnRule.class); +String oldVersion = this.btnRule != null ? this.btnRule.getVersion() : null; this.btnRule = new BtnRuleParsed(btr); Main.getEventBus().post(new BtnRuleUpdateEvent()); try { Files.writeString(btnCacheFile.toPath(), r.body(), StandardCharsets.UTF_8); } catch (IOException ignored) { } log.info(tlUI(Lang.BTN_UPDATE_RULES_SUCCESSES, this.btnRule.getVersion())); setLastStatus(true, "Loaded from remote, version: " + this.btnRule.getVersion()); -btnNetwork.getModuleMatchCache().invalidateAll(); +if (!this.btnRule.getVersion().equals(oldVersion)) { + btnNetwork.getModuleMatchCache().invalidateAll(); + log.debug("Invalidated module match cache due to rule version change"); +}This change will only invalidate the cache when the rule version has changed, potentially reducing unnecessary cache invalidations.
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java (4)
Line range hint
166-175
: Consider improving error handling and logging inreloadConfig()
While the cache invalidation is a great addition, consider the following improvements to the
reloadConfig()
method:
- Catch more specific exceptions instead of the broad
Throwable
. This allows for more targeted error handling.- Enhance the error logging to include details about which part of the reload process failed. This will aid in debugging and maintenance.
- Consider implementing a rollback mechanism or ensuring atomic updates to prevent partial configuration updates in case of exceptions.
Example:
private void reloadConfig() { try { // Existing code... getCache().invalidateAll(); } catch (IOException e) { log.error("Failed to read configuration file", e); rollbarErrorReporter.error(e); } catch (SQLException e) { log.error("Database error during rule update", e); rollbarErrorReporter.error(e); } catch (Exception e) { log.error("Unexpected error during configuration reload", e); rollbarErrorReporter.error(e); } }This approach provides more granular error handling and logging, making it easier to diagnose and address specific issues.
Line range hint
166-171
: Address potential thread safety issues inreloadConfig()
The
reloadConfig()
method modifies shared resources without proper synchronization, which could lead to race conditions and inconsistent state. Consider the following improvements:
- Use atomic operations or synchronization when updating
banDuration
.- Make
ipBanMatchers
thread-safe, e.g., by usingCollections.synchronizedList()
or aConcurrentHashMap
.- Implement a reader-writer lock mechanism to ensure that reads are blocked during the entire reload process.
Example:
private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); private final Lock readLock = rwLock.readLock(); private final Lock writeLock = rwLock.writeLock(); private void reloadConfig() { writeLock.lock(); try { // Existing reload logic... getCache().invalidateAll(); } finally { writeLock.unlock(); } } // In methods that read the configuration public CheckResult shouldBanPeer(...) { readLock.lock(); try { // Existing logic... } finally { readLock.unlock(); } }This approach ensures thread-safe updates to the configuration and consistent reads across threads.
Line range hint
78-106
: Consider enhancing the caching mechanismThe current caching implementation in
shouldBanPeer()
is good, but consider the following enhancements:
- Document the cache configuration (e.g., expiration policy, maximum size) in the class or method comments.
- Implement explicit error handling for cache operations. For example:
try { return getCache().readCacheButWritePassOnly(this, peer.getPeerAddress().getIp(), () -> { // Existing logic... }, true); } catch (CacheException e) { log.warn("Cache operation failed, falling back to direct check", e); // Perform the check without caching return performCheckWithoutCache(torrent, peer, downloader, ruleExecuteExecutor); }
- Consider adding cache statistics logging to monitor cache performance and hit rates.
These improvements will make the caching mechanism more robust and easier to maintain.
Line range hint
1-487
: Consider refactoring for improved modularity and maintainabilityThe
IPBlackRuleList
class is well-structured but quite large. Consider the following refactoring suggestions to improve modularity and maintainability:
- Extract the rule loading and parsing logic into a separate
RuleLoader
class.- Create a
RuleUpdater
class to handle the periodic update logic.- Move the database interaction methods to a separate
RuleRepository
class.- Consider using the Strategy pattern for different types of rules (e.g., remote URL, local file).
Example structure:
class IPBlackRuleList { private RuleLoader ruleLoader; private RuleUpdater ruleUpdater; private RuleRepository ruleRepository; // Core logic and coordination } class RuleLoader { // Rule loading and parsing logic } class RuleUpdater { // Periodic update logic } class RuleRepository { // Database interaction methods }This refactoring would make the code more modular, easier to test, and simpler to maintain. It would also allow for easier extension of functionality in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
- src/main/java/com/ghostchu/peerbanhelper/btn/BtnNetwork.java (2 hunks)
- src/main/java/com/ghostchu/peerbanhelper/btn/ability/BtnAbilityRules.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java (11 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/MultiDialingBlocker.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/PeerIdBlacklist.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHGeneralController.java (3 hunks)
🧰 Additional context used
🔇 Additional comments (18)
src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHGeneralController.java (1)
6-6
: LGTM: New import statement is correctly placed.The import for
ModuleMatchCache
is appropriately added and aligns with the new field introduction.src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/PeerIdBlacklist.java (2)
Line range hint
93-102
: Approve code cleanup, but consider performance implications.The removal of commented-out code improves readability and maintainability. However, this change has removed caching altogether for the
shouldBanPeer
method, which might impact performance for repeated checks on the same peer ID.Consider the following points:
- This change deviates from the PR objective of invalidating the cache for rule checking, as it removes caching entirely.
- There might be a performance impact for scenarios with frequent checks on the same peer ID.
Suggestion: Instead of removing caching completely, consider implementing a cache with a short TTL (Time To Live) or using a more fine-grained cache invalidation strategy. This would align better with the PR objective and potentially offer better performance.
To assess the impact of this change, please run the following script to check for other uses of caching in similar contexts:
87-87
: Approve cache invalidation on config reload.The addition of
getCache().invalidateAll();
ensures that the cache is cleared when the configuration is reloaded, which aligns with the PR objective. This is a good practice to maintain data consistency.To ensure the robustness of this implementation, please verify:
- The thread-safety of the
invalidateAll()
method.- Proper initialization of the cache before this method is called.
You can use the following script to check the cache implementation:
src/main/java/com/ghostchu/peerbanhelper/btn/BtnNetwork.java (2)
7-7
: LGTM: Import statement for ModuleMatchCache.The import statement for
ModuleMatchCache
is correctly placed and necessary for the new field added to the class.
Line range hint
1-165
: Summary: Good additions, clarification needed on cache usageThe changes in this file are minimal and well-structured:
- A new import for
ModuleMatchCache
has been added.- A new
@Autowired
fieldmoduleMatchCache
has been introduced.These changes align with the PR objective of invalidating caches during data updates. However, the new field is not yet used in the existing methods.
To fully realize the benefits of this addition:
- Consider implementing cache invalidation logic in relevant methods like
configBtnNetwork()
orclose()
.- Ensure that any new methods utilizing this cache are thread-safe, as this class uses a
ScheduledExecutorService
.Overall, the changes look good, but their full implementation seems to be pending.
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java (11)
93-93
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when cities are deleted from the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
104-104
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when new cities are added to the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
125-125
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when regions are deleted from the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
135-135
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when ASNs are deleted from the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
145-145
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when ports are deleted from the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
158-158
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when IP addresses are deleted from the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
170-170
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when new regions are added to the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
179-179
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when new ASNs are added to the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
189-189
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when new ports are added to the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
198-198
: LGTM: Cache invalidation added correctlyThe addition of
getCache().invalidateAll();
aftersaveConfig();
ensures that the cache is properly invalidated when new IP addresses are added to the blacklist. This change aligns with the PR objective of invalidating the cache when data is updated.
Line range hint
1-458
: Overall assessment: Changes align with PR objectiveThe changes in this file consistently implement cache invalidation after updating the blacklist data, which aligns well with the PR objective. The cache is properly invalidated in all methods that modify the blacklist (add/delete operations for cities, regions, ASNs, ports, and IPs).
A minor suggestion was made to remove unnecessary operations from the
handleIPTest
method, which appears to be a test method.These changes should effectively ensure that the cache is invalidated when data is updated, allowing for proper rule checking on subsequent operations.
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java (2)
171-171
: Excellent addition: Cache invalidation after config reloadThe addition of
getCache().invalidateAll();
at the end of thereloadConfig()
method is a crucial improvement. This ensures that after reloading the configuration, including updating rules and ban durations, any cached data based on the old configuration is cleared. This change enhances data consistency and guarantees that all subsequent operations will use the newly loaded configuration.
Line range hint
1-487
: Summary: Good addition with opportunities for further improvementsThe addition of cache invalidation after config reload is a positive change that enhances data consistency. However, this review has identified several areas for potential improvement:
- Thread safety: Implement proper synchronization mechanisms to prevent race conditions and ensure consistent state across threads.
- Error handling: Enhance the error handling in the
reloadConfig()
method to catch more specific exceptions and provide more detailed logging.- Caching: Document the cache configuration and implement explicit error handling for cache operations.
- Class structure: Consider refactoring the class to improve modularity and separation of concerns, possibly by extracting separate classes for rule loading, updating, and database interactions.
These improvements would significantly enhance the robustness, maintainability, and performance of the
IPBlackRuleList
class. Consider addressing these points in future iterations of the code.
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java
Show resolved
Hide resolved
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java
Show resolved
Hide resolved
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.
是否所有reloadConfig
被调用时都需要清除缓存?
如果是的话com.ghostchu.peerbanhelper.module.impl.rule.*
下还有大量reloadConfig
没有改动
另外一些 module 里,自建的缓存是否也应该清除?(比如ProgressCheatBlocker
的progressRecorder
和ActiveMonitoringModule
的diskWriteCache
)
reloadConfig 已修改完成 自建缓存不需要清除,它们仅用于追踪目的,修改配置文件不会对这些缓存造成影响的话就无需清除。 |
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (3)
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ClientNameBlacklist.java (1)
Potential Performance Impact Due to Multiple
shouldBanPeer
InvocationsThe
shouldBanPeer
method is invoked across multiple modules and classes, including:
RuleFeatureModule.java
AutoRangeBan.java
ProgressCheatBlocker.java
PeerIdBlacklist.java
MultiDialingBlocker.java
IPBlackList.java
ExpressionRule.java
IPBlackRuleList.java
BtnNetworkOnline.java
PeerBanHelperServer.java
This extensive usage indicates that removing the caching mechanism could lead to performance degradation, especially if these invocations occur frequently or under high load. It's advisable to monitor the application's performance after merging this change and consider implementing alternative optimization strategies if necessary.
🔗 Analysis chain
Line range hint
92-101
: LGTM: Direct rule matching, but consider performanceThe removal of the cache reading logic and direct matching against the rules ensures that the latest rules are always applied, which aligns with the PR objective. This change simplifies the method and makes it more straightforward.
However, removing caching might impact performance for frequently accessed client names. Consider monitoring the performance impact of this change, especially if this method is called frequently or with a large number of peers.
To assess the potential performance impact, you can run the following script to check how often this method is called:
If the method is called frequently, you might want to consider implementing a short-lived cache or using a more efficient data structure for rule matching.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check the usage frequency of shouldBanPeer method # Test: Search for method calls to shouldBanPeer rg --type java "shouldBanPeer\(" -C 2Length of output: 8623
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/MultiDialingBlocker.java (1)
Line range hint
1-242
: Review caching strategyThe recent changes indicate an attempt to invalidate the cache at specific points. However, there are inconsistencies in how the cache is accessed and when it's invalidated. It might be beneficial to review the overall caching strategy for this class to ensure it's being used effectively and consistently.
Consider the following points:
- Ensure that cache access is consistent throughout the class (e.g., direct access vs. getter method).
- Review when and where cache invalidation is necessary.
- Consider adding comments to explain the reasoning behind cache invalidations at specific points.
Would you like assistance in conducting a more comprehensive review of the caching strategy for this class?
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ExpressionRule.java (1)
294-296
: Consider adding a log statement for cache invalidationThe addition of cache invalidation is an excellent improvement to ensure consistency after configuration reloads. To enhance observability, consider adding a log statement after the cache invalidation. This would help in debugging and monitoring the system's behavior, especially when troubleshooting cache-related issues.
Example:
getCache().invalidateAll(); log.debug("Cache invalidated after reloading expressions");This addition would provide valuable information during runtime without significantly impacting performance.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (7)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/AutoRangeBan.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ClientNameBlacklist.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ExpressionRule.java (1 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java (12 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java (2 hunks)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/MultiDialingBlocker.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackList.java
- src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/IPBlackRuleList.java
🧰 Additional context used
🔇 Additional comments (5)
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ClientNameBlacklist.java (1)
87-87
: LGTM: Cache invalidation on config reloadThe addition of
getCache().invalidateAll();
in thereloadConfig
method is a good practice. It ensures that the cache is cleared whenever the configuration is reloaded, maintaining data consistency and aligning with the PR objective.src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java (1)
114-114
: Excellent addition to ensure cache consistency!The addition of
getCache().invalidateAll()
at the end of thereloadConfig()
method is a great improvement. This change ensures that all cached entries are invalidated whenever the configuration is reloaded, which aligns perfectly with the PR objectives. By forcing a re-evaluation of rules after configuration changes, you're preventing stale data from being used, which could lead to incorrect rule applications.This modification enhances the overall reliability of the system by maintaining consistency between the configuration and the applied rules.
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ExpressionRule.java (2)
295-295
: Excellent addition for cache invalidationThe addition of
getCache().invalidateAll();
after reloading the expressions is a crucial improvement. This ensures that any cached results based on old rules are cleared when the configuration is reloaded. This change directly addresses the PR objective of invalidating the cache when rules are updated, which will prevent stale evaluations and ensure that all subsequent rule checks use the most up-to-date configurations.
Line range hint
1-371
: Overall assessment: Excellent improvement with minimal changesThe addition of cache invalidation in the
reloadConfig
method is a well-placed and important improvement. It directly addresses the PR objective of ensuring that rule updates are immediately reflected in the system's behavior. The change is minimal, non-disruptive, and integrates seamlessly with the existing codebase.The
ExpressionRule
class maintains its overall structure and functionality while gaining this important consistency enhancement. No further changes are necessary for this file, as the modification achieves its intended purpose effectively.src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/AutoRangeBan.java (1)
90-90
: Good addition: Invalidate cache upon configuration reloadAdding
getCache().invalidateAll();
in thereloadConfig()
method ensures that the cache is cleared when the configuration is reloaded. This change aligns with the PR's objective to ensure that updated rules take effect immediately, improving data consistency.
@@ -137,6 +137,7 @@ private void reloadConfig() { | |||
maximumSize(TORRENT_PEER_MAX_NUM). | |||
softValues(). | |||
build(); | |||
getCache().invalidateAll(); |
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.
Fix undefined method getCache()
The getCache()
method is not defined in this class. Since cache
is a static field, you can directly access it.
Apply this fix:
- getCache().invalidateAll();
+ cache.invalidateAll();
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
getCache().invalidateAll(); | |
cache.invalidateAll(); |
|
||
getCache().invalidateAll(); |
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.
Reconsider cache invalidation in genPeerGroup()
- The empty line at 213 seems unnecessary and can be removed for consistency.
- The
getCache()
method is undefined, similar to the previous instance. - Invalidating the cache within
genPeerGroup()
might not be necessary or could have unintended side effects, as this method is creating and returning a new Cache object.
Consider the following changes:
- Remove the empty line.
- If cache invalidation is necessary here, use
cache.invalidateAll();
instead ofgetCache().invalidateAll();
. - Evaluate whether cache invalidation is needed in this method at all.
-
- getCache().invalidateAll();
+ // Consider if cache invalidation is necessary here
+ // If it is, use: cache.invalidateAll();
Committable suggestion was skipped due to low confidence.
目前当规则更新、用户修改规则时,不会使缓存失效。这样当一个 Peer 通过特定检查后,由于其处于高速缓存中,导致更改不生效。本 PR 在更新数据时,清除所有高速缓存,使得其被重新检查。
Summary by CodeRabbit
Summary by CodeRabbit
New Features
ModuleMatchCache
in key classes to streamline cache handling.Bug Fixes
Refactor