typhoon / opcache
PSR-16 compliant cache that stores values as PHP files, suitable for OPcaching.
Fund package maintenance!
www.tinkoff.ru/cf/5MqZQas2dk7
Installs: 5 571
Dependents: 2
Suggesters: 0
Security: 0
Stars: 9
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- psr/clock: ^1.0
- psr/log: ^1.0 || ^2.0 || ^3.0
- psr/simple-cache: ^3.0
- typhoon/exporter: ^0.2.0@dev
Requires (Dev)
- ergebnis/composer-normalize: ^2.42
- friendsofphp/php-cs-fixer: ^3.49.0
- infection/infection: ^0.27.9
- mikey179/vfsstream: ^1.6.11
- phpunit/phpunit: ^10.5.10
- phpyh/coding-standard: ^2.6.0
- psalm/plugin-phpunit: ^0.18.4
- symfony/finder: ^6.4 || ^7.0.0
- vimeo/psalm: ^5.22.1
Provides
README
PSR-16 compliant cache that stores values as PHP files, suitable for OPcaching.
Installation
composer require typhoon/opcache
Usage
use Typhoon\OPcache\TyphoonOPcache; $cache = new TyphoonOPcache('path/to/cache/dir'); $cache->set('key', $value); assert($cache->get('key') == $value);
How to configure default TTL
According to PSR-16:
If a calling library asks for an item to be saved but does not specify an expiration time, or specifies a null expiration time or TTL, an Implementing Library MAY use a configured default duration.
Here's how you can configure default TTL:
use Typhoon\OPcache\TyphoonOPcache; $cache = new TyphoonOPcache( directory: 'path/to/cache/dir', defaultTtl: new DateInterval('T1M'), );
How to delete stale cache items
use Typhoon\OPcache\TyphoonOPcache; $cache = new TyphoonOPcache('path/to/cache/dir'); $cache->prune();