wruczek / php-file-cache
Light, simple and standalone PHP in-file caching class
Installs: 20 180
Dependents: 2
Suggesters: 0
Security: 0
Stars: 41
Watchers: 7
Forks: 9
Open Issues: 2
Requires
- php: >=5.4.0
Requires (Dev)
- php: >=5.6.0
- phpunit/phpunit: 5.6.*
README
Light, simple and standalone PHP in-file caching class
Advantages
- Light, standalone and simple
- All code in one file - no pointless drivers.
- Secure - every generated cache file have a php header with
die
, making direct access impossible even if someone knows the path and your server is not configured properly - Well documented and tested
- Handles concurrency correctly via flock
- Supports PHP 5.4.0 - 7.1+
- Free under a MIT license
Requirements and Installation
You need PHP 5.4.0+ for usage and PHP 5.6+ for development (PHPUnit)
Require with composer:
composer require wruczek/php-file-cache
Usage
<?php use Wruczek\PhpFileCache\PhpFileCache; require_once __DIR__ . "/vendor/autoload.php"; $cache = new PhpFileCache(); $data = $cache->refreshIfExpired("simple-cache-test", function () { return date("H:i:s"); // return data to be cached }, 10); echo "Latest cache save: $data";
See examples for more