nytris / cache
v0.0.4
2024-08-27 11:43 UTC
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
实现了一个使用任何符合PSR-6规范的缓存(如Symfony Cache)的ReactPHP缓存。
使用方法
使用Composer安装此包
$ composer require nytris/cache
当使用Nytris平台(推荐)时
配置Nytris平台
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;
注意事项
- PSR-6缓存适配器可能会阻塞,如果发生这种情况,那么ReactPHP事件循环将被阻塞。使用PSR缓存适配器的责任在于消费应用程序,不要使用会阻塞的PSR缓存适配器。