Example of APC cache usage in PHP

Source: Internet
Author: User
Tags apc bool install php php file php download delete cache

APC Full name alternative PHP cache, can be cached PHP source files, can also cache user data, the following we install him, see how to query cache, modify cache, delete cache and other functions

memory of the previous PHP file uploaded to the server need to use Zend Guard encryption, with APC on it.   The message from Wikipedia is that the APC will be built into the PHP6, so the APC is still worth learning.   1, installation extension in Ubuntu 12.04 can be installed directly through the Apt-get install PHP-APC installation APC expansion. 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 have a little bit of attention: 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, find the following two lines of code to modify it: The code is 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, look at the following several additions, queries, modifications, delete examples.     Add a cache with a valid time of 3,600 seconds 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 a key value of name:     There are hit times, size, expiration time, and so on.   Query cache     code as follows: Apc_add (' name ', ' Tom ', 3600); Print Apc_fetch (' name '); Output Tom     Modify cache   code as follows: Apc_store (' name ', ' Anny ', 3600); Print Apc_fetch (' name '); Output Anny     Delete cache   code as follows: Apc_delete (' name '); Var_dump (Apc_fetch (' name ')); output bool (false)     decreasing number   If the contents of the cache are numbers, you can use APC_ Inc to 1,apc_dec self minus 1.   Code as follows: Apc_add (' num ', 10); Apc_inc (' num '); Print apc_fetch (' num ');//Output one apc_dec (' num '); Print apc_fetch (' num ')//output     to determine whether the cache exists   code as follows: Apc_add (' name ', ' Tom ', 3600); Var_dump (apc_exists (' name ')); output bool (TRUE) Var_dump (apc_exists (' age ')); BOOL (FALSE)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.