PHP Classes
elePHPant
Icontem

PHP Fast Cache Class: Cache a script output to avoid running it again

Recommend this page to a friend!

  Author Author  
Name: Lluís Camino <contact>
Classes: 2 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 1x


  Detailed description   Download Download .zip .tar.gz  
This package can cache a script output to avoid running it again.

It can check if a given cache file exists in a given cache directory.

If the file does not exist or it was created after a time more than the cache expiry time, the class starts capturing the output of the current script. Otherwise, it outputs the previous cached content.

If the cached content was not yet previously stored in the cache file or it was stored but it already expired, the class stores the current script output in the cache file after the script ends.

Details

fast-cache

Simple caching system for PHP applications.

Installing

Use the following command to install via Composer:

composer require lluiscamino/fast-cache

Usage

$cache = new FastCache(21600); // Cache lifetime in seconds
$cache->start();
echo "Hola!"; // Display content
$cache->end();

Once a user visits your website for the first time, a cached version of the page will be created and served for the following requests in the specified time.

If for some reason you don't want the current content to be saved, you can finish with $cache->end(false); and the content will not be cached.

Apart from time, you can also specify two more parameters in the constructor:

__construct(int $time, string $file = null, string $dir = '')
  • string $file: Name of the (file.php) that identifies the page being cached. Use this option to create different cached versions of the same page. Leave blank to automatically select the file from which the object is being created.
  • string $dir: Subdirectory where the cache file of the page will be saved.

Configuration

FastCache::$path = 'custom-dir'; // Cache files directory
FastCache::$announce = false; // Disable "Serving cached file fromServing cached file from..." comment

  Classes of Lluís Camino  >  PHP Fast Cache Class  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  

 

Name: PHP Fast Cache Class
Base name: fast-cache
Description: Cache a script output to avoid running it again
Version: 1.0.0
PHP version: 7
License: Custom (specified in a license file)
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Files and Folders Listing, accessing and manipulating files and folders View top rated classes
Group folder image Cache Classes for managing cached pages View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagedocs (1 file)
Files folder imagesrc (1 directory)
Plain text file composer.json Data Auxiliary data
Plain text file LICENSE Lic. License text
Plain text file README.md Doc. Documentation

  Files folder image Files  /  docs  
File Role Description
  Plain text file FastCache.pdf Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imagelluiscamino (1 file)

  Files folder image Files  /  src  /  lluiscamino  
File Role Description
  Plain text file FastCache.php Class Class source

Download Download all files: fast-cache.tar.gz fast-cache.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.