Remember the previous PHP file uploaded to the server need to first use Zend Guard encryption, with APC is not necessary. The message from Wikipedia is that the APC will be built into the PHP6, so the APC is still worth learning.
1. Installation extension
APC extensions can be installed directly through the Apt-get install PHP-APC in Ubuntu 12.04.
On the Windows system, the author has previously installed in Windows APC, but the operation is not stable, do not know now resolved not. In Windows can replace APC with Wincache, Microsoft developed itself, very stable.
Tips: After the installation is complete, remember to restart the Web server.
2, download apc.php
Download Address: Apc_php.zip
apc.php This script can view the use of APC. The interface is as follows:
There are two tabs that can be a little concerned:
1 System Cache Entries: This means caching options for caching some PHP files in the middle code.
2 User Cache Entries: Represents the caching of user data, in which the user's data can be cached to APC. If you want to view the user data cache, you need to first modify the access account and password. Open the apc.php file and find the following two lines of code to modify it:
Copy Code code as follows:
Defaults (' Admin_username ', ' APC '); Admin Username
Defaults (' Admin_password ', ' PASSWORD '); Admin password-change this to ENABLE!!!
3, APC Use example
APC is very simple to use, look at the following several additions, queries, modifications, delete examples.
Add a cache with a valid time of 3,600 seconds
Copy Code code as follows:
Apc_add (' name ', ' Tom ', 3600);
Execute the code, and then look at the user cache Entries, and you can see one more cached data with the key value name:
There are hit times, sizes, expiration times, and so on.
Query caching
Copy Code code as follows:
Apc_add (' name ', ' Tom ', 3600);
Print Apc_fetch (' name '); Output Tom
Modify Cache
Copy Code code as follows:
Apc_store (' name ', ' Anny ', 3600);
Print Apc_fetch (' name '); Output Anny
Delete Cache
Copy Code code as follows:
Apc_delete (' name ');
Var_dump (Apc_fetch (' name ')); output bool (FALSE)
Decreasing number of increments
If the content of the cache is a number, you can use APC_ Inc to increase 1,apc_dec self minus 1.
Copy Code code as follows:
Apc_add (' num ', 10);
Apc_inc (' num ');
Print apc_fetch (' num ');//Output 11
Apc_dec (' num ');
Print apc_fetch (' num ');//Output 10
To determine if the cache exists
Copy Code code as follows:
Apc_add (' name ', ' Tom ', 3600);
Var_dump (apc_exists (' name ')); output bool (TRUE)
Var_dump (apc_exists (' age ')); BOOL (FALSE)