PHP Cache Module Cache (APC) _php Tutorial

Source: Internet
Author: User
Tags apc apc module posix

PHP Cache Module Cache (APC)


APC is the abbreviation for alternative PHP cache and is a free, publicly available, optimized code cache for PHP. It is used to provide 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 annotations in front of the Extension=php_apc.dll.
The configuration parameters of the APC module are as follows:

Apc.enabled

Type: Boolean type
Apc.enabled can be set to a% to disable APC. This is mostly useful when 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 php.ini).

Apc.shm_segments

Type: Integral type
The number of shared memory blocks allocated to the compilation cache. If the APC is running out of shared memory and you have set Apc.shm_size to the maximum allowable value for 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, the size of shared memory blocks for some systems (including most BSD variant systems) is very low.

Apc.optimization

Type: Integral type
Optimization level. Set to 0 to disable optimization, the higher the value the more powerful the optimization is used. Expect to have moderate speed improvements. This is still an experimental nature.

Apc.num_files_hint

Type: Integral type
A hint to 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 that have 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 filled with stale entries and that new entries cannot be cached.

Apc.gc_ttl

Type: Integral type
The number of seconds that the cache 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 set by this parameter is reached. Setting to 0 disables this feature.

Apc.cache_by_default

Type: Boolean type
The default is on, but can be set to off and used with the apc.filters with the plus sign, and the file is cached only when matching the filter.

Apc.filters

Type: string
A comma-delimited list of POSIX extended regular expressions. If any pattern matches the source file name, 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 +, then 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 MMAP support is compiled for APC using –ENABLE-MMAP (enabled by default), the value here is the Mktemp-style file mask that is passed to the Mmap module (the recommended value is "/TMP/APC". XXXXXX "). This mask is used to determine if the memory-mapped area is to be file-backed or shared memory backed. For direct file-backed memory mapping, set to "/TMP/APC". XXXXXX "(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 memory that is mapped anonymously. Undefined this directive means that anonymous mappings are enforced.


Apc.slam_defense

Type: Integral type
On a very busy server, whether you start the service or modify the file, you will cause a multi-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 single process that skips the cache's chances. 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 likely it will be to reduce the probability of collisions with the cache. Set to 0 to disable this feature.

Apc.file_update_protection

Type: Integral type
When you modify a file on a running server, you should perform atomic operations. That is, write a temporary file, and then rename (MV) the file to its final location when you finish writing it. Many text editors, Cp,tar, and other similar programs do not. This means there is a chance to access and (cache) the file when the file is still being written. The Apc.file_update_protection setting allows the cache to mark the delay of a new file. The default value is 2, which means that files will not be cached if they are found to be less than 2 seconds away from the time the file was modified. The unfortunate user who accesses half of the files will see the bizarre situation, but at least this is not a continuous situation. If you are sure that you often use atomic operations to update your files, you can turn this protection off by setting this parameter to 0. If your system is full of IO operations and causes the updater to take more than 2 seconds, you may need to increase this value.

Apc.enable-cli

Type: Integral type
Mostly for testing and debugging. Start the APC function for CLI version PHP. In general, you will not expect to create, port, and discard APC caches for each CLI request, but for various test scenarios it is easy to open 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

 
  


http://www.bkjia.com/PHPjc/871189.html www.bkjia.com true http://www.bkjia.com/PHPjc/871189.html techarticle The PHP Cache module Cache (APC) APC is the abbreviation for alternative PHP cache and is a free public optimized code cache for PHP. It is used to provide free, open and robust architecture to slow ...

  • 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.