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

Resolved issues with cache driver not being used #2760

Draft
wants to merge 1 commit into
base: 7.dev
Choose a base branch
from

Conversation

bryannielsen
Copy link
Contributor

There are parts of the core that override the user's choice of cache driver and require the file cache. This is confusing and particularly problematic in serverless environments where the file driver is not useful. This change attempts to standardize more functionality and always rely on the user selected cache driver.

Copy link
Contributor

@intoeetive intoeetive left a comment

Choose a reason for hiding this comment

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

Please see comments on code.

Also noting that we need to actually test this when using driver different than file

if (! ee()->cache->file->is_supported()) {
if (! ee()->cache->is_writable() && ee()->cache->get_adapter() == 'file') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about this change.

The docs are requiring /user/cache folder to be writable, and it has always been like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will just always throw a warning if EE is deployed to a serverless host where system/user/cache cannot be writable. Another option would be to allow the cache folder to be configurable. Usually the /tmp folder is writable even in these environments but still the file cache driver doesn't work because the machine is destroyed after every request.

Copy link
Contributor

Choose a reason for hiding this comment

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

So does that mean you can set cache driver to "dummy", have system/user/cache folder NOT writeable and EE still would work as expected (thinking of query caching, tag caching, template caching)?
I think we need to actually test that before making this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this definitely needs some testing, I just wanted to get the PR open so we could start that process. I think we should target a later release for this after it has been tested thoroughly.

EE should still function with any cache driver set otherwise I would think that's a fault with the caching system. In my opinion caching shouldn't be necessary but should provide a performance benefit when enabled. Anyone choosing to use the dummy driver should still have a functioning site but gaining no performance benefit.

Copy link
Contributor

Choose a reason for hiding this comment

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

The cache directory (PATH_CACHE) is also being used for other things (exporting, running 1-click updates etc.). If it's not writable, EE will not function correctly. If some environments can't make it writable, then we need a fix for those cases - not removing the check.

I'm fine with other changes, but not this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I did a search on PATH_CACHE and it looks like it's being used in a lot of places to write files where we should really refactor to using the cache driver.

Updates are something we'll need to think about, they aren't really possible in a serverless environment without a persistent filesystem mount. So perhaps this warning should be tied to if 1-click updates are enabled in the config? We really just need some way for people running EE on a serverless environment with a read-only disk to not see this warning on every page load.

*/
public function is_writable($key = '', $scope = Cache::LOCAL_SCOPE)
{
if(method_exists($this->{$this->_adapter}, 'is_writable')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

needs a space after if

@intoeetive intoeetive marked this pull request as draft January 27, 2023 08:05
@intoeetive intoeetive added this to the 7.x milestone Jan 27, 2023
@intoeetive intoeetive modified the milestones: 7.4.0, 7.x Jul 6, 2023
@bryannielsen bryannielsen self-assigned this Mar 26, 2024
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.

None yet

2 participants