Alternative PHP cache (APC) 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.
APC official website for HTTP://PECL.PHP.NET/PACKAGE/APC
Extension module under Windows download address Http://www.sitebuddy.com/php/accelerators/apc_windows_binaries_builds
Under Windows, APC requires a c:mp directory, and the directory is writable to the WEB server process.
1. Installation
Install in PHP extension form
2. Configuration
Apc.enabled Boolean
Apc.optimization optimization
Options can be changed in the script
An explanation of APC php.ini configuration options
[APC]
; Alternative PHP cache for caching and optimizing PHP intermediate code
Apc.cache_by_default = On
; SYS
; Whether buffering is enabled by default for all files.
; If set to off and used with the apc.filters instruction that starts with a plus sign, the file is cached only when matching the filter.
APC.ENABLE_CLI = Off
; SYS
; Whether APC functionality is enabled for the CLI version, which is only opened for testing and debugging purposes.
apc.enabled = On
; If APC is enabled, it is the only option if APC is statically compiled into PHP and wants to disable it.
Apc.file_update_protection = 2
; SYS
; When you modify a file on a running server, you should perform atomic operations.
; That is, first write a temporary file, and then rename the file (MV) to the final name.
; The text editor, as well as the CP, tar and other programs do not operate this way, resulting in the possibility of buffering the mutilated files.
; The default value of 2 indicates that the modification time is not buffered if the access time is less than 2 seconds when the file is accessed.
; The unfortunate visitor may get incomplete content, but the bad effect is not amplified by the cache.
; If you can ensure that all update operations are atomic, you can turn this feature off with 0.
; If your system is slow to update due to a large number of IO operations, you need to increase this value.
Apc.filters =
; SYS
; A comma-delimited list of POSIX-extended regular expressions.
; If the source file name matches any one of the patterns, the file is not cached.
; Note that the filename used to match is the file name passed to Include/require, not the absolute path.
; If the first character of a regular expression is "+" it means that any file matching the expression is cached.
; If the first character is "-" none of the matches will be cached. "-" is the default value and can be omitted.
Apc.ttl = 0
; SYS
; The number of seconds that the cache entry is allowed to stay in the buffer. 0 means never time out. The recommended value is 7200~36000.
; A setting of 0 means that the buffer may be filled with old cache entries, causing the new entries to be cached.
Apc.user_ttl = 0
; SYS
; Similar to Apc.ttl, the recommended value is 7200~36000 for each user.
; A setting of 0 means that the buffer may be filled with old cache entries, causing the new entries to be cached.
Apc.gc_ttl = 3600
; SYS
; The number of seconds that a cache entry can exist in the garbage collection table.
; This value provides a security measure, even if a server process crashes while executing the cached source file.
; And the source file has been modified, and the memory allocated for the old version is not recycled until this TTL value is reached.
; Set to zero disables this attribute.
Apc.include_once_override = Off
; SYS
; Please remain off, otherwise it may result in unexpected results.
Apc.max_file_size = 1M
; SYS
; Prohibit files larger than this size from being cached.
Apc.mmap_file_mask =
; SYS
; If you have compiled MMAP support 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.num_files_hint = 1000
; SYS
; Approximate number of different source files that may be included or requested on the Web server (recommended value is 1024~4096).
; If you are unsure, set to 0; This setting is primarily for sites that have thousands of source files.
apc.optimization = 0
; Optimization level (recommended value is 0).
; A positive integer value indicates that the optimizer is enabled, and the higher the value, the more aggressive the optimization is used.
; Higher values may have a very limited speed boost, but are still being tested.
Apc.report_autofilter = Off
; SYS
; Whether to log all scripts that are not cached automatically because of the early/late binding reason.
Apc.shm_segments = 1
; SYS
; The number of shared memory blocks allocated for the compiler buffer (recommended value is 1).
; If the APC runs out of shared memory and the apc.shm_size instruction is set to the maximum allowable value for the system,
; You can try to increase this value.
Apc.shm_size = 30
; SYS
; The size of each shared memory block (in megabytes, recommended value is 128~256).
; Some systems, including most BSD variants, have very few default shared memory block sizes.
Apc.slam_defense = 0
; SYS (against using the directive, it is recommended to use the Apc.write_lock Directive)
; On a very busy server, whether it's starting a service or modifying a file,
; Can cause a race condition because multiple processes are attempting to cache a file at the same time.
; This instruction is used to set the percentage of the process that skips cache steps when processing files that are not cached.
; For example, set to 75 indicates that there is a 75% probability of not caching when a file is not cached, thus reducing the chance of collisions.
; Encourage set to zero to disable this feature.
Apc.stat = On
; SYS
; Whether to enable the script update check.
; Be very careful to change this command value.
; The default value on indicates that APC checks that the script is updated every time the script is requested.
; If updated, the compiled content is automatically recompiled and cached. But doing so has a detrimental effect on performance.
; If set to Off, no check is made, resulting in a significant performance gain.
; However, in order for the updated content to take effect, you must restart the Web server.
; This command is also valid for Include/require files. But it's important to note that
; If you are using a relative path, APC must check each time Include/require to locate the file.
; Using an absolute path allows you to skip the check, so you are encouraged to use an absolute path for include/require operations.
Apc.user_entries_hint = 100
; SYS
; Similar to the Num_files_hint directive, only for each different user.
; If you are not sure, set to 0.
Apc.write_lock = On
; SYS
; Whether write locks are enabled.
; On a very busy server, whether it's starting a service or modifying a file,
; Can cause a race condition because multiple processes are attempting to cache a file at the same time.
; Enabling this directive avoids the appearance of competitive conditions.
apc.rfc1867 = Off
; SYS
; After you open the directive, for each upload file that contains the Apc_upload_progress field exactly before the file field,
; APC will automatically create a Upload_ user cache entry (that is, the Apc_upload_progress field value).
3. Functions
Apc_cache_info-retrieves cached information (and Meta-data) from APCs data store
Apc_clear_cache-clears the APC cache
Apc_define_constants-defines a set of constants for later retrieval and mass-definition
Apc_delete-removes a stored variable from the cache
Apc_fetch-fetch a stored variable from the cache
Apc_load_constants-loads a set of constants from the cache
Apc_sma_info-retrieves APCs Shared Memory Allocation Information
Apc_store-cache a variable in the data store
The use of APC is relatively simple, with only a few functions, listed below.
Apc_cache_info () returns cache information
Apc_clear_cache () clears APC cache content.
By default (no parameters), only the system cache is cleared, to clear the user cache, the ' user ' parameter is required.
Apc_define_constants (string key, array constants [, BOOL Case_sensitive]) adds the array constants to the cache with constants.
Apc_load_constants (String Key).
Remove the constant cache.
Apc_store (string key, mixed var [, int ttl]).
Save the data in the cache.
Apc_fetch (string key).
Get cached content Saved by Apc_store
Apc_delete (string key).
Delete Apc_store saved content.
Management of APC:
To pecl.php.net download the APC source package there is a apc.php,copy where your Web server can access it and browse to it.
The management interface features are:
1. Refresh Data
2. View Host Stats
3. System Cache Entries
4. User Cache Entries
5. Version Check
http://www.bkjia.com/PHPjc/508271.html www.bkjia.com true http://www.bkjia.com/PHPjc/508271.html techarticle Alternative PHP cache (APC) 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. APC Officer ...