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

Added yii\caching\CallbackDependency to allow using a callback to determine if a cache dependency is still valid #20137

Merged
merged 6 commits into from
Apr 13, 2024

Conversation

laxity7
Copy link
Contributor

@laxity7 laxity7 commented Mar 23, 2024

Using a callback function is more convenient to use than a string, as in yii\caching\ExpressionDependency.

Q A
Is bugfix?
New feature? ✔️
Breaks BC?

Copy link

what-the-diff bot commented Mar 23, 2024

PR Summary

  • Introduction of yii\caching\CallbackDependency in various language guides
    The yii\caching\CallbackDependency class, a new caching tool, has been added to several documentation guides. These are resources that assist developers, and are now available in a variety of languages—Spanish, French, Japanese, Portuguese, Russian, Chinese, and English.

  • Inclusion of yii\caching\CallbackDependency class to framework
    The yii\caching\CallbackDependency class has also been integrated into the main framework. This new functionality will empower developers to handle caching dependencies in a more flexible manner.

  • Modification of generateDependencyData method
    The generateDependencyData method, used for creating dependency data, found in FileDependency.php has been updated. The alterations will improve how dependencies are being processed.

  • Addition of test cases for yii\caching\CallbackDependency
    Tests for the newly added yii\caching\CallbackDependency have been introduced. This testing helps validate the correct functioning of the new class, ensuring that it works reliably and as expected. It's a big step towards achieving higher quality and stability in our software.

…etermine if a cache dependency is still valid
Copy link

codecov bot commented Mar 23, 2024

Codecov Report

Attention: Patch coverage is 22.22222% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 46.70%. Comparing base (923c309) to head (1ecdbe5).

❗ Current head 1ecdbe5 differs from pull request most recent head 848ddf9. Consider uploading reports for the commit 848ddf9 to get more accurate results

Files Patch % Lines
framework/caching/FileDependency.php 0.00% 4 Missing ⚠️
framework/caching/CallbackDependency.php 50.00% 2 Missing ⚠️
framework/classes.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master   #20137       +/-   ##
=============================================
- Coverage     64.82%   46.70%   -18.13%     
=============================================
  Files           429      446       +17     
  Lines         37074    43917     +6843     
=============================================
- Hits          24034    20510     -3524     
- Misses        13040    23407    +10367     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@rob006 rob006 left a comment

Choose a reason for hiding this comment

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

IMO this needs some documentation how to configure serialization to handle closures - I suspect that most users will try to use this class with anonymous functions, and it won't work by default, because PHP does not handle serializing closures by default and Yii does not do anything to work around this limitation.

framework/caching/FileDependency.php Outdated Show resolved Hide resolved
@laxity7
Copy link
Contributor Author

laxity7 commented Apr 12, 2024

@samdark is't possible to merge or is there something else to do?

framework/CHANGELOG.md Outdated Show resolved Hide resolved
@samdark samdark merged commit 8861f7b into yiisoft:master Apr 13, 2024
63 of 71 checks passed
@samdark
Copy link
Member

samdark commented Apr 13, 2024

Thanks.

@samdark samdark added this to the 2.0.50 milestone Apr 13, 2024
@rob006 rob006 mentioned this pull request May 16, 2024
@OndrejVasicek
Copy link
Contributor

Doesn't CallbackDependency make ExpressionDependency obsolete?
Also - I can't see info about the class in the guide on web, even though it's in this PR. I can't even find in in the API - https://www.yiiframework.com/doc/api/2.0/yii-caching-dependency

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.

4 participants