<?php class Cache { private $dir = "data/cache/";//定义缓存目录 private $key='c_a_sss'; // 文件名 md5加密 密钥 function set_dir($dirpath) { $this->dir=$dirpath; $this->make_dir($this->dir); } function read($key,$minutes=1) { $filename=$this->get_filename($key); if($datas = @file_get_contents($filename)) { $datas = unserialize($datas); if(time() - $datas['time'] < $minutes*60) { return $datas['data']; } } return false; }
The cache is the buffer for data exchange (called Cache). When a piece of hardware wants to read data, it will first search for the required data from the cache. If it is found, it will be executed directly. If it cannot be found, it will be executed from the cache. Search in memory. Since the cache runs much faster than the memory, the role of the cache is to help the hardware run faster
Because the cache often uses RAM (non-permanent storage that is lost when power is turned off), so when it is used up In the end, the files will still be sent to storage such as hard drives for permanent storage. 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.
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
15 Jul 2016
20 extremely useful PHP libraries. Below are some very useful PHP libraries, which I believe can provide a better and faster method for your WEB development. Chart libraries The following libraries allow you to easily create complex charts.
13 Jul 2016
24 useful PHP libraries to share, 24php libraries. 24 useful PHP libraries to share, 24php libraries Currently, PHP is the most popular scripting language used for web development. You can easily find a lot of information about PHP on the Internet, including documentation, tutorials,
13 Jul 2016
Recommend 25 very useful class libraries in PHP and 25 non-Chinese class libraries in PHP. Recommended 25 very useful class libraries in php, 25 non-class libraries in php Snappy Snappy is PHP5 used to generate thumbnails, snapshots, PDF, URL or HTML pages. It uses the excellent WebKit-based wkht
06 Jul 2016
What are some very useful class libraries or tool libraries for PHP?
10 Apr 2018
The content of this article is to recommend 25 very useful class libraries in PHP. It has certain reference value. Friends in need can refer to it.
20 Jul 2016
20 very useful PHP libraries that you must collect. 20 very useful PHP libraries that you must collect. This article provides the names and download addresses of 20 very useful PHP libraries. These 20 PHP libraries include icon libraries, RSS parsing, and thumbnail generation
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images