https://github.com/thybag/php-simple-cache
A simple PHP file caching library
https://github.com/thybag/php-simple-cache
Last synced: 8 months ago
JSON representation
A simple PHP file caching library
- Host: GitHub
- URL: https://github.com/thybag/php-simple-cache
- Owner: thybag
- Created: 2018-12-09T16:09:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-09T16:12:24.000Z (over 7 years ago)
- Last Synced: 2025-07-19T18:04:32.456Z (11 months ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Php simple cache
A quick simple PHP file caching library. Not recommended for production use.
License: MIT
#### Features:
* Optional ability to bypass cache (for debugging)
* Human readable cache keys/paths
* Fallback to old cache on failure to load new data
* Talkative logging (Requires PSR logger)
## Usage
`composer require thybag/php-simple-cache`
```
// Standard
$cache = new \thybag\PhpSimpleCache\Cache;
$result = $cache->get("key");
// static
$result = \thybag\PhpSimpleCache\StaticCache::get("key")
```
#### Methods
* **read**($cache_key, $max_age, $fallback) - read an item from the cache. Return fallback if item is to old.
* **write**($cache_key, $data) - write data to cache
* **delete**($cache_key, $recursivedDelete) - delete item from cache (or entire folder optionally)
* **has**($key, $max_age) - do we have a no stale version cached
* **age**($cache_key) - current age of cache item (false if no cache found)
* **get**($cache_key, $callback, $max_page) - run a callback, caching contents
Settings can be changed via
* **setLogger**(PSR logger)
* **setOptions**(['cache_path'=>, 'allow_cache_bypass', 'cache_bypass_keyword', 'default_ttl'])