|Last Updated|| ||Ratings|| ||Unique User Downloads|| ||Download Rankings|
|2020-02-12 (1 month ago) ||Not yet rated by the users||Total: 62 ||All time: 9,648 This week: 373|
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.
Simple caching system for PHP applications.
Use the following command to install via Composer:
composer require lluiscamino/fast-cache
$cache = new FastCache(21600); // Cache lifetime in seconds
echo "Hola!"; // Display content
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.
FastCache::$path = 'custom-dir'; // Cache files directory
FastCache::$announce = false; // Disable "Serving cached file fromServing cached file from..." comment
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.