nytris / cache
Installs: 1 774
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=8.1
- psr/cache: ^1.0
- react/cache: ^1.2
- react/promise: ^3.2 || ^2.11
Requires (Dev)
- mockery/mockery: 1.6.11
- phpstan/phpstan: ^1.10
- phpstan/phpstan-mockery: ^1.1
- phpunit/phpunit: ^10.2
- symfony/cache: ^5.4
- tasque/event-loop: ^0.1.5
- tasque/tasque: ^0.1.8
README
Implements a ReactPHP cache using any PSR-6-compliant cache such as Symfony Cache.
Usage
Install this package with Composer:
$ composer require nytris/cache
When using Nytris platform (recommended)
Configure Nytris platform:
nytris.config.php
<?php declare(strict_types=1); use Nytris\Boot\BootConfig; use Nytris\Boot\PlatformConfig; use Nytris\Cache\Adapter\ReactCacheAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; $bootConfig = new BootConfig(new PlatformConfig(__DIR__ . '/var/cache/nytris/')); $bootConfig->installPackage(new MyNytrisPackage( // Using Symfony Cache adapter as an example. cachePoolFactory: fn (string $cachePath) => new ReactCacheAdapter( new FilesystemAdapter( 'my_cache_key', 0, $cachePath ) ) )); return $bootConfig;
Caveats
- PSR-6 cache adapters may block, if so then the ReactPHP event loop will be blocked. It is the responsibility of the consuming application to not use PSR cache adapters that block.