<?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
06 Jul 2016
What are some very useful class libraries or tool libraries for PHP?
13 Dec 2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...
11 Nov 2024
Hidden Truths: The Leading Underscore in PHP Class MethodsWhen browsing PHP libraries, one might stumble upon class methods prefixed with a...
06 Jul 2016
I have seen many open source projects in the form of class.classname.php, but I have also seen many frameworks in the form of classname.class.php. Where should I place this class? I personally prefer the .class.php form, because in some frameworks, after importing third-party class libraries and specifying class libraries...
09 Nov 2024
Why Do Some PHP Class Methods Begin with an Underscore?While exploring PHP libraries, you might have noticed that certain developers prefer to...
28 Oct 2024
Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...
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