Skip to content

APC driverClear fails #680

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

Closed
spud opened this issue Mar 25, 2019 · 3 comments
Closed

APC driverClear fails #680

spud opened this issue Mar 25, 2019 · 3 comments

Comments

@spud
Copy link

spud commented Mar 25, 2019

Configuration

  • PhpFastCache version: 7.0.2 (but the code appears the same in 7.0.5)
  • PhpFastCache API version: 2.0.4
  • PHP version: 7.2.14
  • Operating system: (MAMP Pro 5.3 on MacOS 10.13)

The APC driver's "driverClear" method, which should clear the entire cache, has been failing me. I make changes, clear the cache, and earlier cached data persists. So I started digging for answers.

I found driverClear in /Drivers/APC/Driver.php, which executes:

return @apc_clear_cache() && @apc_clear_cache('user');

And should return "true." After a bunch of debugging statements and trials, I discovered that reducing the function to

apc_clear_cache('user')

worked fine, and cleared my cache! It turns out that, despite the official PHP documentation, apc_clear_cache() returns NULL. Consequently, the 'user' version never gets executed, and that's what actually clears the cache.

My current configuration is using the "APC" driver, though APCu appears to also be installed under MAMP (see attached screenshot). I'm not sure what effect that may have on this behavior, but as-is, there seems to be a bug in the APC-only version. I have had to hack the Driver.php file in order to allow my cache-clearing mechanism to work properly.

Strangely, apc_clear_cache('user') properly returns a boolean rather than NULL, so simply omitting the parameter-less version (or even inverting the order) would at least execute the clearing before choking on the NULL.

Screen Shot 2019-03-25 at 5 16 51 PM

@Geolim4
Copy link
Member

Geolim4 commented Mar 26, 2019

Hello,

You suggest that I would change the code for return @apc_clear_cache() || @apc_clear_cache('user'); ?

@spud
Copy link
Author

spud commented Mar 26, 2019 via email

Geolim4 added a commit that referenced this issue Mar 27, 2019
@Geolim4
Copy link
Member

Geolim4 commented Mar 27, 2019

A commit has been added to address the issue. It should be available in the next release, in the meantime you can use dev-master :)

Thanks you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants