nytris/cache

维护者

详细信息

github.com/nytris/cache

源代码

问题

安装: 446

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

公开问题: 0

类型:项目

v0.0.4 2024-08-27 11:43 UTC

This package is auto-updated.

Last update: 2024-08-27 11:45:11 UTC


README

Build Status

实现了一个使用任何符合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缓存适配器。