Instructions for using php cache files extracted from CI framework

黄舟
Release: 2023-03-15 13:34:02
Original
2064 people have browsed it

The php file cache class extracted from the CI community's stblog and CI's file_helper class, a simple file-based key->value cache class. This class can be used to cache some basic information, such as some infrequent changes in the header, footer, and sidebar of the blog, and the content taken out from the database. Before fetching the data, first determine whether the content in the file cache has expired. If it has not expired, take it out. , if it expires, connect to the database to query, rewrite the results into the file cache, and update the expiration time.

First download the php cache file class extracted from CI that we need to use in this course: http://www.php.cn/xiazai /leiku/478

After the download is complete, find the php class file we need, unzip it to our local directory, and create a new php file!

After completion, we need to call this class in the new php file and instantiate the class:

<?php

include_once "cache1.php";//引入类文件
$cache = new FileCache(30,&#39;cache/&#39;); //实例化
$cache->set(&#39;test&#39;,&#39;php中文网:www.php.cn&#39;);
print $cache->get(&#39;test&#39;);
?>
Copy after login

The running result is as shown below:

Instructions for using php cache files extracted from CI framework

Create a cache folder below the directory, which contains our file cache:

Instructions for using php cache files extracted from CI framework

The above is the detailed content of Instructions for using php cache files extracted from CI framework. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!