https://github.com/gueff/cachix
A simple PHP Caching Class working with files
https://github.com/gueff/cachix
cache caching php
Last synced: about 1 year ago
JSON representation
A simple PHP Caching Class working with files
- Host: GitHub
- URL: https://github.com/gueff/cachix
- Owner: gueff
- Created: 2017-12-05T09:52:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-22T13:45:15.000Z (about 3 years ago)
- Last Synced: 2025-04-24T00:08:48.638Z (about 1 year ago)
- Topics: cache, caching, php
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cachix
A simple PHP Caching Class working with files
## Requirements
- PHP >= 7.4
- Linux commands `rm`, `find` and `grep` to be executable via PHP's `shell_exec` command
## Installation
create the composer.json file with following content:
~~~
{
"require": {
"gueff/cachix":"1.0.2"
}
}
~~~
run installation
~~~
$ composer install
~~~
## Usage
~~~php
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);
}
~~~