php—Alternative PHP Cache (optional PHP cache)

伊谢尔伦
Release: 2016-11-22 09:54:00
Original
1338 people have browsed it

Introduction and installation configuration

Alternative PHP Cache (APC) is an open and free PHP opcode cache. Its goal is to provide a free, open, and sound framework for caching and optimizing PHP intermediate code.

The installation packages for each version of the extension are here: http://pecl.php.net/package/apc.

The DLL of the PECL extension is currently unavailable.

Note: On Windows, APC needs a temporary directory, and the Web server can write to this directory. APC will detect the Windows environment variables such as TMP, TEMP, and USERPROFILE. If these are not found, it will check the WINDOWS under the system folder. Table of contents.

The behavior of these functions is affected by settings in php.ini.

Although the default APC settings are fine for most installations, professionals should consider adjusting the following parameters.

APC has two main configuration options. First, how much memory will be allocated to APC; second, whether APC checks for file modifications every time it is requested. Two ini options control these settings apc.shm_size and apc.stat respectively.

Once the server is running, the apc.php script can be copied to a web directory that can be accessed through the browser. Accessing this script through the browser will get a detailed analysis of the APC working status, if the GD extension is enabled in PHP , it even displays some interesting graphs. Of course, the first thing to do is to make sure the file is actually cached. If APC is running, the Cache Full Statistics number (in the upper left corner) will show the cache hit rate and clear caches that have not been accessed in the last apc.ttl seconds. This number enables a good configuration of cache minimization. If the cache is constantly being filled and cleared, this will affect cache effectiveness and script performance. The best way to reduce this number is to allocate enough memory to APC. In addition to this, fewer scripts can be cached via apc.filters.

For more introductory articles about APC, please refer to: Optional PHP cache APC analysis - installation, configuration and working principle

APC function

apc_add — cache a variable to data storage

apc_bin_dump — Get a binary dump of the given files and user variables

apc_bin_dumpfile — Output a binary dump of cached files and user variables to a file

apc_bin_load — Load a binary dump into the APC file/user cache

apc_bin_loadfile — Load a binary dump from a file into the APC file/user cache

apc_cache_info — Get cache information from APC’s data store

apc_cas — Update old value to new value

apc_clear_cache — Clear APC cache

apc_compile_file — Stores a file in the bytecode cache, bypassing all filters.

apc_dec — Reduce a stored number

apc_define_constants — Defines a set of constants for retrieval and mass-definition

apc_delete_file — Delete a file from bytecode

apc_delete — Delete a variable from the user cache

apc_exists — Check whether a certain key or keys exist in the APC

apc_fetch — Fetch stored variables from the cache

apc_inc — Increment a stored number

apc_load_constants — Load a series of constants from the cache

apc_sma_info — Fetch Back to APC's shared memory allocation information

apc_store — Cache a variable in the data store

APCIterator class

APCIterator class makes it easier to traverse large APC caches, which is helpful because it allows to fetch every defined The number of entries for the locked instance, so it releases other active cache locks rather than blocking the entire cache to complete the iteration of fetching 100 (default) cache data on large cache entries. In addition, using regular matching is more efficient because it is changed to a C-level implementation.

Method list

APCIterator::__construct — Construct an APCIterator iterator object

APCIterator::current — Get the current item

APCIterator::getTotalCount — Get the total number

APCIterator::getTotalHits — Get the number of cache hits

APCIterator ::getTotalSize — Get the size of all caches

APCIterator::key — Get iterator key Get the key of the iterator

APCIterator::next — Move to the next item

APCIterator::rewind — Rewind the iterator

APCIterator ::valid — Check if the current location is valid


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!