Skip to content

APC driverClear fails  #680

@spud

Description

@spud

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions