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

[NFR]: Automatic Expiration of Phalcon\Annotations Cache Based on Source File Modification Time #16473

Open
ytcheng opened this issue Dec 14, 2023 · 1 comment
Labels
new feature request Planned Feature or New Feature Request

Comments

@ytcheng
Copy link

ytcheng commented Dec 14, 2023

Description:

Currently, in the Phalcon\Annotations component, various adapters rely on manual cache clearing to update the annotations cache. I propose implementing an automatic mechanism that checks the modification time of the source files and automatically expires the cache when changes are detected. This would eliminate the need for manual intervention to keep the annotations cache up-to-date.

Benefits:

  1. Effortless Maintenance: Developers won't have to manually clear the cache every time a source file is modified, reducing the risk of overlooking updates.

  2. Real-time Reflection: Automatic cache expiration ensures that annotations reflect the most recent changes in the source code, providing an accurate representation of the current state of the application.

  3. Improved Development Workflow: This enhancement streamlines the development workflow by removing the burden of cache management, allowing developers to focus more on coding and less on cache-related tasks.

Implementation Suggestion:

Revise each Phalcon\Annotations adapter to inspect the modification time of associated source files each time annotations are accessed. If a change is detected, automatically invalidate the cache related to the modified file. This approach ensures that the cache remains synchronized with the latest changes in the source code without relying on periodic, scheduled checks.

Additional Consideration:

Allow developers to configure the frequency of these checks or provide a sensible default that balances real-time reflection with minimal performance impact.

Note:

I believe this enhancement would contribute to a more seamless development experience with Phalcon\Annotations, and I look forward to hearing the community's thoughts and feedback on this proposal.

@ytcheng ytcheng added the new feature request Planned Feature or New Feature Request label Dec 14, 2023
@noone-silent
Copy link

Implementation Suggestion:

Revise each Phalcon\Annotations adapter to inspect the modification time of associated source files each time annotations are accessed. If a change is detected, automatically invalidate the cache related to the modified file. This approach ensures that the cache remains synchronized with the latest changes in the source code without relying on periodic, scheduled checks.

Wouldn't that render all caching useless? If you have to check the file, then you can actually also parse it.

If you are developing, there are flags to recheck a view or annotations or to keep them in memory per request. If you go production, you should invalidate all caches and regenerate it only once for the current release. Most people I know have this in their CI or release scripts.

If you just talk about local development, you can just use other Adapters like Memory or write a cli task to invalidate caches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

No branches or pull requests

2 participants