gueff / cachix
A simple PHP Caching Class working with files
Installs: 3 236
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2025-01-22 17:57:56 UTC
README
A simple PHP Caching Class working with files
Requirements
- PHP >= 7.4
- Linux commands
rm
,find
andgrep
to be executable via PHP'sshell_exec
command
Installation
create the composer.json file with following content:
{
"require": {
"gueff/cachix":"1.0.2"
}
}
run installation
$ composer install
Usage
<?php // init Config \Cachix::init(array( 'bCaching' => true, 'sCacheDir' => '/tmp/', 'iDeleteAfterMinutes' => 10, 'sBinRemove' => '/bin/rm', 'sBinFind' => '/usr/bin/find', 'sBinGrep' => '/bin/grep' )); // build a Cache-Key $sKey = 'myCacheKey.Token'; // autodelete cachefiles // which contain the string ".Token" in key-names \Cachix::autoDeleteCache('.Token'); // first time saving data to cache... if (empty(\Cachix::getCache($sKey))) { // Data to be cached $aData = ['foo' => 'bar']; \Cachix::saveCache( $sKey, $aData ); } // ...or read from existing Cache else { $aData = \Cachix::getCache($sKey); }