Alternative PHP Cache (APC) stores the bytecode of previous PHP compilations so we do not need to recompile every time thereby saving time. We have to clean the cache entries for a fresh compilation. For this purpose, we can use the PHP function apc_clear_cache() to remove cache entries. This command clears the cache and returns “true” on success.
This command will remove system cache. If you want to clear cache for user, then simply provide “user” as the parameter.
Example: To clear APC cache, copy and paste the following code in your PHP file. Be sure to replace the string ‘Your IP address’ with your actual IP Address. If the cache is cleared successfully, an alert box with a “success” message is shown otherwise “error” alert message is displayed.
Now lets us run this code for any webpage. Check out the following code. We have created a simple web page and we have added a variable to APC cache. We have created a variable “$name” with value “abc” and saved it to APC cache using the function apcu_add() with parameters where “name” is a unique key, $name is the actual variable and the last argument is TTL (Time To Live) i.e. the time for the variable stored in the cache.
To verify the variable, we have displayed cache information using function apcu_cache_info() and we see our variable is added to cache.
We can see our name variable that has been added to the cache as the total entries are one and in info, we can see our name variable.
Now to clear the cache we press “clear cache” button. The cache is cleared and displayed. We see that the new cache entries are 0 and info is empty thereby showing that cache has been cleared.
We can compare both the caches and check the command executed successfully.
The cache is successfully cleared.
Note: If you are not a developer but a system administrator, you can clear the cache by reloading your server and if it is not work, kill the server signal and restart.
- D3.js | d3.entries() Function
- D3.js | d3.map.entries() Function
- Node.js | Buffer.entries() Method
- HTML DOM NodeList.entries() Method
- D3.js nest.entries() function
- Lodash _.entries() Method
- HTTP headers | cache-control
- Why does SASS cache folder is created ?
- PHP | Imagick clear() Function
- PHP | Ds\Collection clear() Function
- PHP | DS\Map clear() Function
- PHP | Ds\Vector clear() Function
- PHP | Gmagick clear() Function
- PHP | Ds\Set clear() Function
- PHP | Ds\Deque clear() Function
- PHP | Ds\Stack clear() Function
- PHP Ds\PriorityQueue clear() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.