I. APC installation Configuration
Refer to my article
II. php. ini configuration item [APC] section details
[Apc]
; Alternative php cache for caching and optimizing php intermediate code
Apc. cache_by_default = on
; Sys
Whether to enable caching for all files by default.
If it is set to off and used together with the apc. filters command starting with the plus sign, the file is cached only when the filter is matched.
Apc. enable_cli = off
; Sys
Whether to enable the apc function for the cli version. This command is enabled only for testing and debugging purposes.
Apc. enabled = on
Whether to enable apc. If apc is statically compiled into php and you want to disable it, this is the only way.
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, cp, tar, and other programs do not perform this operation, which may buffer incomplete files.
The default value is 2, indicating that the file is not buffered if the modification time is found to be less than 2 seconds away from the Access time.
The unfortunate visitor may get incomplete content, but this bad effect will not be extended through the cache.
If you can ensure that all update operations are atomic operations, you can disable this feature with 0.
; If your system updates slowly due to a large number of io operations, you need to increase this value.
Apc. filters =
; Sys
; A list of posix extension Regular Expressions separated by commas.
If the source file name matches any mode, the file is not cached.
Note: The file name used for matching is the file name passed to include/require, rather than the absolute path.
If the first character of the regular expression is "+", it means that any file that matches the expression will be cached,
If the first character is "-", no match will be cached. "-" Is the default value, which can be omitted.
Apc. ttl = 0
; Sys
The number of seconds that cache entries can stay in the buffer. 0 indicates never timeout. Recommended Value: 7200 ~ 36000.
If it is set to 0, the buffer may be filled with old cache entries, resulting in the inability to cache new entries.
Apc. user_ttl = 0
; Sys
; Similar to apc. ttl, the recommended value is 7200 ~ for each user ~ 36000.
If it is set to 0, the buffer may be filled with old cache entries, resulting in the inability to cache new entries.
Apc. gc_ttl = 3600
; Sys
The number of seconds that cache entries can exist in the garbage collection table.
This value provides a security measure, even if a server process crashes when the cached source file is executed,
And the source file has been modified, and the memory allocated for the old version will not be recycled until the ttl value is reached.
If it is set to zero, this feature is disabled.
Apc. include_once_override = off
; Sys
; There is no instruction document for this directive, see: http://pecl.php.net/bugs/bug.php? Id = 8754
; Keep it off. Otherwise, unexpected results may occur.
Apc. max_file_size = 1 m
; Sys
; Files larger than this size cannot be cached.
Apc. mmap_file_mask =
; Sys
If you use-enable-mmap (enabled by default) to compile mmap support for apc,
The value here is the mktemp file mask passed to the mmap module (Recommended Value: "/tmp/apc. xxxxxx ").
The mask is used to determine whether the memory ing area is file-backed or shared memory backed.
For direct file-backed memory ing, set it to "/tmp/apc. xxxxxx" (exactly 6 x ).
To use the posix shm_open/mmap style, you must set it to "/apc. shm. xxxxxx.
You can also set it to "/dev/zero" to use the kernel "/dev/zero" interface for anonymous ing memory.
If this command is not defined, anonymous ing is mandatory.
Apc. num_files_hint = 1000
; Sys
The approximate number of different source files that may be contained or requested on the web server (Recommended Value: 1024 ~ 4096 ).
If you are not sure, set it to 0. This setting is mainly used for websites with thousands of source files.
Apc. optimization = 0
; Optimization level (Recommended Value: 0 ).
The positive integer value indicates that the optimizer is enabled. The higher the value, the more radical optimization is used.
; A higher value may have a very limited speed increase, but it is still being tested.
Apc. report_autofilter = off
; Sys
; Whether to record all scripts that are automatically not cached due to early/late binding.
Apc. shm_segments = 1
; Sys
; The number of shared memory blocks allocated to the compiler buffer (Recommended Value: 1 ).
If apc consumes shared memory and the apc. shm_size command is set to the maximum value allowed by the system,
; You can try to increase this value.
Apc. shm_size = 30
; Sys
; The size of each shared memory block (in mb, recommended value: 128 ~ 256 ).
Some systems (including most bsd variants) have very few default shared memory blocks.
Apc. slam_defense = 0
; Sys (opposed to using this command, we recommend using the apc. write_lock command)
On very busy servers, whether it is to start the service or modify files,
; May be caused by multiple processes attempting to cache a file at the same time.
This command is used to set the percentage of cached steps skipped by a process when processing files that are not cached.
For example, if it is set to 75, it indicates that no cache is performed for files that are not cached, reducing the chance of collision.
We recommend that you set it to 0 to disable this feature.
Apc. stat = on
; Sys
; Whether to enable the script Update check.
Be very careful when changing the command value.
The default value on indicates that apc checks whether the script is updated every time it requests the script,
If updated, the compiled content is automatically re-compiled and cached. However, this has a negative impact on performance.
If it is set to off, the check is not performed, which greatly improves the performance.
To make the updated content take effect, you must restart the web server.
This command is also valid for include/require files. However, you must note that,
If you are using a relative path, apc must check each include/require operation to locate the file.
You can skip the check using the absolute path. Therefore, you are encouraged to use the absolute path for the include/require operation.
Apc. user_entries_hint = 100
; Sys
; Similar to the num_files_hint command, only for different users.
If you are not sure, set it to 0.
Apc. write_lock = on
; Sys
Whether to enable the write lock.
On very busy servers, whether it is to start the service or modify files,
; May be caused by multiple processes attempting to cache a file at the same time.
; Enable this command to avoid competition conditions.
Apc. rfc1867 = off
; Sys
After this command is enabled, for each upload file that contains the apc_upload_progress field just before the file field,
Apc will automatically create an upload _ User cache entry (that is, the value of the apc_upload_progress field ).
III. function:
Apc_cache_info-retrieves cached information (and meta-data) from apc's 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 apc's shared memory allocation information
Apc_store-cache a variable in the data store
The usage of apc is relatively simple. There are only a few functions, as listed below.
Apc_cache_info () returns the Cache Information
Apc_clear_cache () clears the apc cache content.
By default (No parameter), only the system cache is cleared. To clear the user cache, you must use the reset user' parameter.
Apc_define_constants (string key, array constants [, bool case_sensitive]) adds the array constants to the cache as constants.
Apc_load_constants (string key ).
Retrieve constant cache.
Apc_store (string key, mixed var [, int ttl]).
Save data in the cache.
Apc_fetch (string key ).
Obtain the cache content saved by apc_store.
Apc_delete (string key ).
Delete the content saved by apc_store.
IV. apc Management
Go to pecl.php.net to download the apc source package. There is an apc. php package. copy it to a place that your web server can access and browse it to access it.
Management interface functions:
1. refresh data
2. view host stats
3. system cache entries
4. user cache entries
5. version check
It is very useful to pay attention to section 4.