php-alternative PHP cache (optional PHP caching)

Source: Internet
Author: User
Tags apc

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 robust framework for caching and optimizing PHP's intermediate code.

The installation packages for each version of the extension are here: HTTP://PECL.PHP.NET/PACKAGE/APC.

The DLL for the pecl extension is currently unavailable.

Note: On Windows, APC requires a temporary directory, and the Web server is writable by this directory, and APC detects tmp,temp,userprofile these Windows environment variables, and if none of these, checks the Windows directory under the System folder.

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

Although the default APC settings are no longer problematic 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 each time it is requested. The two INI options control each of these settings apc.shm_size and Apc.stat.

Once the server is up and running, the apc.php script can be copied to a web directory that can be accessed through a browser, and a browser access to the script will give a detailed analysis of the status of the APC, and it will even show some interesting graphs if the GD extension is enabled in PHP. Of course, the first thing is to make sure that the files are actually cached. If APC is running, the cache full count (in the upper-left corner) displays the cached hit ratio and clears the cache that has not been accessed in the last apc.ttl seconds. This number makes the cache very well configured to minimize. If the cache is constantly being populated and purged, this will affect the performance of the cache and the script. The best way to reduce this number is to allocate enough memory to the APC. In addition, fewer scripts can be cached by apc.filters.

For more information about APC, refer to: Optional PHP cache APC Analysis-installation, configuration and operating principle

APC functions

apc_add-caching a variable to a data store

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-retrieving cache information from the APC data store

apc_cas-update old value to new value

apc_clear_cache-clearing the APC cache

Apc_compile_file-stores a file in the bytecode cache, bypassing all filters.

apc_dec-reduces one storage number

Apc_define_constants-defines a set of constants for retrieval and Mass-definition

apc_delete_file-deleting files from bytecode

apc_delete-Deleting a variable from the user cache

apc_exists-Check if there is some or some key in APC

apc_fetch-to remove stored variables from the cache

apc_inc-increments a stored number

apc_load_constants-loading a series of constants from the cache

Apc_sma_info-Retrieving shared memory allocation information for APC

apc_store-caching A variable in the data store

Apciterator class

The Apciterator class makes it easier to traverse the large-capacity APC cache, which is helpful because it allows you to simultaneously get the number of entries for each locked instance that has been defined, so it frees the cache lock for the other active, rather than blocking the entire cache to complete the iteration of getting 100 (the default) cache data. In the large cache entry. In addition, the use of regular matching is more efficient because it is changed to C-level implementations.

Method List

apciterator::__construct-constructs an Apciterator iterator object

apciterator::current-getting the current item

apciterator::gettotalcount-Get Total

apciterator::gettotalhits-Get Cache Hits

apciterator::gettotalsize-get the size of all caches

Apciterator::key-get iterator key gets the key of the iterator

apciterator::next-move to the next item

Apciterator::rewind-Backwards iterator

apciterator::valid-Check if the current location is valid

  • Related Article

    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.