christopher-paul-shaw / datacache
Cache Data To Disk
Installs: 44
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/christopher-paul-shaw/datacache
Requires
- php: ^5.4 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2025-09-28 02:40:49 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);