Home PHP Libraries Other libraries Simple and efficient file caching php class
Simple and efficient file caching php class
<?php
class FileCache  
{   
    public $keyPrefix = '';   
    public $cachePath = '';   
    public $cacheFileSuffix = '.bin';   
    public $directoryLevel = 1;    
    public $gcProbability = 10;  
    public $fileMode;   
    public $dirMode = 0775;  
    function __construct()  
    {  
        $this->cachePath = HT::$cacheRoot.'htcache';  
    }  
  
    function FileCache()  
    {  
        $this->__construct();  
    }

$dir: cache file storage directory

$lifetime: cache file validity period, in seconds

$cacheid: cache file path, including file name

$ext: Cache file extension (can be omitted), used here for the convenience of viewing the file

Destructor, check whether the cache directory is valid, default assignment, check Whether the cache is valid, write the cache

$mode == 0, obtain the page content through the browser cache

$mode == 1, use direct assignment (received through the $content parameter) Get the page content by

$mode == 2, get the page content by reading locally (fopen ile_get_contents) (it seems that this method is unnecessary)



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 simple data caching class PHP simple data caching class

08 Aug 2016

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

Simple PHP caching class sharing_PHP tutorial Simple PHP caching class sharing_PHP tutorial

13 Jul 2016

Simple php cache class sharing. This article mainly introduces a php cache class. The file name is encrypted using md5. Please use it for reference. The code is as follows:?phpclass Cache{private $dir = data/cache/;//Define the cache directory private $

PHP file caching class, _PHP tutorial PHP file caching class, _PHP tutorial

13 Jul 2016

PHP file caching class,. PHP file cache class, 1 ? php 2 /* * 3 * @desc file cache 4 */ 5 class Cache{ 6 const C_FILE = '/Runtime/' ; 7 private $dir = '' ; 8 const EXT = '.tpl ' ; 9 private $filename = ''

Simple caching class implemented in PHP, caching implemented in php_PHP tutorial Simple caching class implemented in PHP, caching implemented in php_PHP tutorial

13 Jul 2016

A simple cache class implemented by PHP, which implements caching in PHP. Simple cache class implemented in PHP, cache implemented in php This article describes the simple cache class implemented in PHP. Share it with everyone for your reference. The details are as follows: cache.inc.php: phpclass Cache {

Detailed explanation of PHP file caching functions: file caching processing methods of file_get_contents, file_put_contents, unlink and other functions Detailed explanation of PHP file caching functions: file caching processing methods of file_get_contents, file_put_contents, unlink and other functions

18 Nov 2023

Detailed explanation of PHP file caching functions: file caching processing methods of file_get_contents, file_put_contents, unlink and other functions, which require specific code examples. In web development, we often need to read data from files or write data to files. Moreover, in some cases, we need to cache the contents of files to avoid frequent file read and write operations, thus improving performance. In PHP, there are several commonly used functions that can help us implement file caching, including

A simple comprehensive class for database connection and text caching A simple comprehensive class for database connection and text caching

25 Jul 2016

A simple comprehensive class for database connection and text caching

See all articles