Using pear to buffer PHP programs _php Tutorial

Source: Internet
Author: User
Buffering in the PHP World is a hot topic, because PHP generates dynamic pages that need to be recalculated every time a user requests, regardless of whether the requested result is the same, and PHP compiles the script every time. This overload will certainly be unbearable for a high-traffic site. Fortunately, the results of the WEB can be buffered without having to rerun and compile scripts, and commercialized products like Zendcache or open source Alternate PHP cache provide a way to compile PHP scripts into byte code and buffer them.
The PEAR buffer package provides a framework for buffering dynamic content, database queries, and PHP function calls.
Just like Perl has CPAN, TeX has ctan,php also has its own central repository, storage classes, libraries and modules. This library is called PEAR (PHP Extension and add-on Repository).
This article assumes you have installed the PEAR environment, if not, you can go to the PHP website to download.

The PEAR buffer package contains a general buffer class and several special subclasses. Buffer classes use container classes to store and manage buffered data.
Here are the containers currently contained in the PEAR buffer, along with their respective parameters:
File-The Files container stores buffered data in the filesystem, which is the fastest container.
Cache_dir-This is the directory where the container stores the files.
Filename_prefix-The prefix of the buffered file, for example: "Cache_".
SHM-The SHM container puts the buffered data into shared memory, and benchmarks show that the container is slower than the file container at the current implementation.
Shm_key--The key value used for shared memory.
Shm_perm--Permission to use shared memory data segments.
Shm_size--allocates the size of shared memory.
Sem_key--The key value of the semaphore.
Sem_perm--the permission of the semaphore.
DB--PEAR's database abstraction layer.
DSN--The DSN for the database connection. You can refer to the DB documentation for PEAR.
Cache_table--The name of the table.
Phplib--The Phplib container uses the database abstraction layer to store the buffer.
Db_class
Db_file
Db_path
Local_file
Local_path
EXT/DBX-PHP Database Abstraction layer extension, if the buffer is stored as a database, you can use this container.
Module
Host
Db
Username
Password
Cache_table
Persistent
The performance gains from using the PEAR Cache depend on the buffer container you choose, for example, it makes no sense to store the results of the database in the database buffer again.
The function buffer module of the PEAR cache can buffer the results of any function or method, whether it is a PHP built-in function or a user-defined function, he defaults to the file container, putting the buffer data into a called
The Function_cache directory.

The constructor for the Cache_function class can have three optional parameters:

http://www.bkjia.com/PHPjc/629330.html www.bkjia.com true http://www.bkjia.com/PHPjc/629330.html techarticle Buffering in the PHP World is a hot topic, because PHP generates dynamic pages, and each user request needs to be recalculated, regardless of whether the requested result is the same, and PHP every time ...

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