search
HomePHP LibrariesOther librariesVery easy to use php caching class
Very easy to use php caching class
<?
/*
用户需要事先定义的常量:
_CachePath_        模板缓存路径
_CacheEnable_        自动缓存机制是否开启,未定义或为空,表示关闭自动缓存机制
_ReCacheTime_        自动重新缓存间隔时间,单位为秒,未定义或为空,表示关闭自动重新缓存
*/
class cache
{
    var $cachefile;
    var $cachefilevar;
    function cache()
    {
        //生成当前页的Cache组文件名 $this->cachefilevar 及文件名 $this->cachefile
        //动态页的参数不同对应的Cache文件也不同,但是每一个动态页的所有Cache文件都有相同的文件名,只是扩展名不同
        $s=array(".","/");$r=array("_","");
        $this->cachefilevar=str_replace($s,$r,$_SERVER["SCRIPT_NAME"])."_".$_GET[_ActionVar_];
        $this->cachefile=$this->cachefilevar.".".md5($_SERVER["REQUEST_URI"]);
    }

The cache is the buffer for data exchange. When a piece of hardware wants to read data, it will first search the required data from the cache. If it is found, it will be executed directly. If it is not found, it will be searched from the memory. Since cache runs much faster than memory, the purpose of the cache is to help the hardware run faster.

Because cache often uses RAM, the files will still be sent to storage such as hard disks for permanent storage after use. The largest cache in a computer is the memory stick. The fastest ones are the L1 and L2 caches built into the CPU. The video memory of the graphics card is a cache for the graphics card's computing chip. There is also a 16M or 32M cache on the hard disk.


Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP caching class for your own use, your own PHP caching class_PHP tutorialPHP caching class for your own use, your own PHP caching class_PHP tutorial

12Jul2016

My own PHP caching class, my own PHP caching class. PHP cache class for your own use, your own PHP cache class?php/** * Cache class, data implementation, output cache* @author ZhouHr 2012-11-09 http://www.ketann.com * @copyright version 0.1 */ class C

How Do I Link Static Libraries That Depend on Other Static Libraries?How Do I Link Static Libraries That Depend on Other Static Libraries?

13Dec2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

How to Access and Use the BigInteger Class in PHP?How to Access and Use the BigInteger Class in PHP?

21Oct2024

Accessing the Math_BigInteger Class in PHPPHP provides a BigInteger class for handling large integer values beyond the limits of a regular integer data type. It is accessible through the Math_BigInteger class within the Math package. This package can

When to Use `self` vs. `$this` in PHP 5 to Access Class Members?When to Use `self` vs. `$this` in PHP 5 to Access Class Members?

17Dec2024

When to Use 'self' over '$this' in PHP 5In PHP 5, using the correct keyword to refer to class members and methods is crucial. When it comes to the...

How Can I Use the BigInteger Class in PHP to Handle Large Integers?How Can I Use the BigInteger Class in PHP to Handle Large Integers?

21Oct2024

Using BigInteger Class in PHPPHP provides several methods for handling large integer values. The BigInteger class is one such option.Accessing BigInteger ClassThe BigInteger class is not natively available in PHP. However, you can use an external lib

How to Silence TensorFlow\'s Debugging Output?How to Silence TensorFlow\'s Debugging Output?

28Oct2024

Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...

See all articles