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

A very easy-to-use front-end paging js tool classA very easy-to-use front-end paging js tool class

29Sep2017

Share your own encapsulated front-end paging js tool class. Below is a screenshot of the default style effect. You can change js and css at will. It is very flexible.

PHP extension class ZipArchive is easy to usePHP extension class ZipArchive is easy to use

08Aug2016

:This article mainly introduces the simple use of the PHP extension class ZipArchive. Students who are interested in PHP tutorials can refer to it.

Crawler development technology: Use PHP and Selenium to build a first-class web crawlerCrawler development technology: Use PHP and Selenium to build a first-class web crawler

15Jun2023

With the development of the Internet, crawler technology has become an indispensable tool in data acquisition, market analysis, competitive product research and other fields. Among traditional crawler technologies, Python is the preferred language for developing crawler tools. Compared with other languages, Python has the advantages of being easy to learn, concise, and rich in crawler libraries. But today, we are going to introduce another excellent crawler language-PHP, and its efficient techniques for combining with Selenium. 1. What is SeleniumSelenium is a tool that is widely used in Web automation

Very easy to use Zend Framework paging class_PHP tutorialVery easy to use Zend Framework paging class_PHP tutorial

13Jul2016

Very easy to use Zend Framework paging class. Here I would like to share with you a very useful Zend Framework paging class. The specific effect can be seen in the paging effect of this website. The CSS style can be changed according to personal design sense. Here I will give an example

Very easy to use JsonToString method simple example_javascript skillsVery easy to use JsonToString method simple example_javascript skills

16May2016

This article introduces a very easy-to-use simple example of JsonToString. Friends in need can refer to it.

php image processing class (simple and easy to use)php image processing class (simple and easy to use)

25Jul2016

php image processing class (simple and easy to use)

See all articles