How to Clear Apc Cache Entries

How to clear APC cache entries?

You can use the PHP function apc_clear_cache.

Calling apc_clear_cache() will clear the system cache and calling apc_clear_cache('user') will clear the user cache.

How to clear APC cache without crashing Apache?

You can remove the time limit on a script you're running (as long as you don't run php in safe mode)

set_time_limit(0);

This will remove the time limit for the script

http://au2.php.net/manual/en/function.set-time-limit.php for more details

Clearing apcu with a wild card

OP refers to APCu not APC.

There isn't much difference in function names, etc, but it's best for anyone to make clear that APC is the old version, and APCu is the new one, with a much better implementation.

Old APC implements both opcode cache and user object cache. APCu only implements user object cache. For opcode cache you use something else, like Zend OPcache.
That said, here's an updated version from @Evgenly's:

// delete all keys beginning with a regex match
foreach(new APCUIterator('/^MY_KEY/') as $apcu_cache){
echo 'key: ' . $apcu_cache['key'] . PHP_EOL;
echo 'val: ' . $apcu_cache['value'];
apcu_delete($apcu_cache['key']);
}

The foreach is illustrative, you can also do:

apcu_delete(new APCUIterator('/^MY_KEY/'));

APC Clear Directory Entries

Use apc_cache_info to get the list of cached files. Call apc_delete_file on any files that match your mask.

You can also use an APCIterator to find all files that match your mask and then delete them. Note that you'll want to move the iterator to the next file before you delete the previous one. Or make an array of all matching filenames using the iterator and then delete them from your own array. Modifying a collection while traversing it is tricky.

There is no single call that does this.

Do I need to clear APC cache after new post?

No, APC cache has to be cleared only after PHP files modification.
Ad you shouldn't clear full cache, use apc_compile_file() only for files that you uploaded/modified (http://uk.php.net/manual/en/function.apc-compile-file.php)

How to flush the APC cache in Prestashop

To flush the APC user cache, you have to install the administration interface for APC (apc.php). This file is bundled with the download for APC. Just copy it to a folder that is accessible from the web, the edit it to set a password.

After that, you can connect and flush the cache when needed. It is possible to flush the system cache and the user cache separately.



Related Topics



Leave a reply



Submit