christopher-paul-shaw / datacache
There is no license information available for the latest version (0.0.2) of this package.
Cache Data To Disk
0.0.2
2019-02-16 18:34 UTC
Requires
- php: ^5.4 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2024-10-28 00:17:01 UTC
README
A PHP Class to cache frequently accessed Data to a file.
This is intended to be used to cache larger datasets such as database reports to prevent repetative and time / resource consuming data queries.
Usage
$file = "my-cache-file"; // File to Use for Cache
$time = "300"; // Seconds to Cache For
$cache = new DataCache($file, $time);
$data = $cache->read();
// Output Cached Version if present
if ($data) {
die($data);
}
// Write to Cache and Output of not present
$data = rand(1,15);
$cache->write($data);
die($data);