APC - clearing cache with cron jobs

1.1k Views Asked by At

I have a system that runs with Apache - APC is enabled and SLI is on

My Intention:

I use several crons to update stuff, once this cron has taken place it also clears certain cache related to these updates. This was all working fine when I was using curl to open the file however I decided to switch to make this via the cron itself by enabling APC SLI in the configuration.

The Problem: The cron works perfectly fine, no errors no nothing, however it does not clear the cache, is there certain code related to this that has to be changed if I want to use it in SLI rather then curl?

This is the code:

$deletesallupdates = new APCIterator('user', '/^USER.updates/', APC_ITER_VALUE);
apc_delete($deletesallupdates);

My APC configuration:

[APC]
extension = apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 1024M
apc.max_file_size = 2M
apc.stat = 1
apc.enable_cli = 1
2

There are 2 best solutions below

2
On

Have you tried using apc_clear_cache? And have you tried Zend OpCache (available for PHP 5.2 and newer)? That one has more precise functions to manage your cache.

0
On

As I understand it, there are separate caches for APC when PHP is running in CLI mode and when it is running as an apache module.

It might be that your cron jobs are working 'correctly', but as they are accessing a different cache (the APC CLI cache) than that which your application is using.