yii2
yii2 copied to clipboard
yii\base\Module createControllerByID add cache
Q | A |
---|---|
Is bugfix? | ❌ |
New feature? | ❌ |
Breaks BC? | ❌ |
Fixed issues | #20114 |
PR Summary
-
Enhanced Caching Mechanism in
Module.php
The update in this file involves the addition of a caching feature to thecreateControllerByID
method. The method initially checks whether there's a cache present for a given ID. If the cache doesn't exist, it continues with the standard procedure. On the other hand, if the cache is present, it retrieves the associated class name. It then verifies whether the class name exists and certifies that it is a subclass ofyii\base\Controller
. This enhancement is designed to improve the retrieval speed of information, making our services more efficient.
Codecov Report
Attention: 4 lines
in your changes are missing coverage. Please review.
Comparison is base (
0027227
) 48.02% compared to head (29567a9
) 48.02%.
Files | Patch % | Lines |
---|---|---|
framework/base/Module.php | 82.60% | 4 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #20115 +/- ##
=======================================
Coverage 48.02% 48.02%
=======================================
Files 445 445
Lines 43892 43900 +8
=======================================
+ Hits 21080 21084 +4
- Misses 22812 22816 +4
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I sure hope no one is seriously thinking adding this PR into codebase, this is type of stuff that may kill the framework
I will do a simple test, using the microtime (true) function to calculate the difference, and replacing preg_replace_callback with cache in the createControllerByID function does indeed improve the calculation time, but it increases the complexity and instability risk of the system. So I gave up.