PHP Cache Module Cache (APC)

Source: Internet
Author: User
Tags anonymous apc apc module expression garbage collection posix string version

APC is the abbreviation of alternative PHP cache and is a free public optimized code cache for PHP. It is used to provide a free, open and robust architecture to cache and optimize PHP's intermediate code.

1, PHP configuration APC

To open the APC module, you need to remove the comments in front of the Extension=php_apc.dll.
The configuration parameters for the APC module are as follows:

Apc.enabled

Type: Boolean
Apc.enabled can be set to 0来 disable APC. This is primarily useful when the APC is statically compiled into PHP because there is no other way to disable it (when compiling to DSO, you can comment out the extension line in the php.ini).

apc.shm_segments

Type: Integral type
The number of shared memory blocks allocated to the compilation cache. If the APC runs out of shared memory, and you have set the apc.shm_size to the maximum allowed by the system, you can try to increase the value of this parameter.

apc.shm_size

Type: Integral type
The size of each shared memory block is in megabytes. By default, some systems (including most BSD variant systems) have a low size limit for shared memory blocks.

apc.optimization

Type: Integral type
Optimization level. Set to 0 disables optimization, and the higher the value, the stronger the optimization. Look forward to a modest improvement in speed. This is still experimental in nature.

Apc.num_files_hint

Type: Integral type
Tips on the number of different source files that are included and requested on your Web server. If you are unsure, set to 0 or omit; This setting may be used primarily for sites with thousands of source files.

Apc.ttl

Type: Integral type
When a cache entry is required by another entry in the buffer location, we need to consider the number of seconds that the cache entry is allowed to be idle in the buffer location. Setting this parameter to 0 means that your cache may be full of stale entries and that new entries cannot be cached.

Apc.gc_ttl

Type: Integral type
The number of seconds the cached entry survives in the garbage collection list. This value provides an error protection in the event that a cache source file is executed while the server process is dead. If the source file is modified, the memory allocated to the old version of the cache entry will not be recycled until the TTL value is set to this parameter. Setting to 0 prohibits this feature.

Apc.cache_by_default

Type: Boolean
The default is on, but it can be set to off and used in conjunction with a apc.filters that starts with a plus sign, and the file is cached only when the filter is matched.

apc.filters

Type: string
A comma-separated list of POSIX-extended regular expressions. If any pattern matches the source filename, the file will not be cached. Note the filename used to match is the file name passed to Include/require, not the absolute path. If the first character of the regular expression is +, the expression means that any file that matches the expression will be cached, and if the first character is-then no match will be cached. -Is the default value, so it can be omitted.

Apc.mmap_file_mask

Type: string
If you compile MMAP support for APC using –ENABLE-MMAP (default enabled), the value here is the Mktemp-style file mask passed to the Mmap module (the recommended value is/TMP/APC. XXXXXX "). The mask is used to determine whether the memory-mapped area is to be file-backed or shared memory backed. For a direct file-backed memory mapping, set to "/TMP/APC." XXXXXX "appearance (exactly 6 x). To use POSIX-style shm_open/mmap, you need to set it to "/apc.shm.xxxxxx." You can also set the "/dev/zero" to use the kernel's "/dev/zero" interface for anonymous mapped memory. Not defining this directive means enforcing the use of anonymous mappings.


Apc.slam_defense

Type: Integral type
On very busy servers, whether you start a service or modify a file, you can cause a multiple process to try to cache the same file at the same time. This option sets the percentage of the process skipping attempts to cache a file that is not cached. Or you can think of this as a chance for a separate process to skip caching. For example, setting Apc.slam_defense to 75 means that the process has a 75% chance of not caching files that are not cached. Therefore, the higher the setting, the more it can reduce the collision probability of the cache. This attribute is disabled when set to 0.

apc.file_update_protection

Type: Integral type
When you modify a file on a running server, you should perform an atomic operation. That is, write a temporary file first, and then rename (MV) the file to its final position when it is finished. Many text editors, Cp,tar, and other similar programs do not operate this way. This means that there is a chance to access and (cache) the file when the file is still being written. The Apc.file_update_protection setting causes the cache to mark the delay of the new file. The default value is 2, which means that if the file is found to be modified for less than 2 seconds, the file will not be cached. Unfortunate users who visit half of the files will see bizarre situations, but at least this is not sustainable. If you are sure that you often use atomic operations to update your files, you can turn off this protection by setting this parameter to 0. If your system is full of IO operations and causes the update to take more than 2 seconds, you may need to increase the value.

apc.enable-cli

Type: Integral type
Most are for testing and debugging. Start the APC feature for CLI version of PHP. In general, you will not think of creating, porting, and discarding the APC cache for each CLI request, but for a variety of test scenarios it is easy to turn on the APC for the CLI version.


Case:
apc.enabled = 1
Apc.shm_segments = 1
Apc.shm_size = 64
apc.optimization = 0
Apc.num_files_hint = 1000
Apc.ttl = 0
Apc.gc_ttl = 3600
Apc.cache_by_default = On
Apc.slam_defense = 0
Apc.file_update_protection = 2
APC.ENABLE_CLI = 0
Apc.stat=0

2, APC Cache case

 
  




Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.