nytris/cache

Maintainers

Details

github.com/nytris/cache

Source

Issues

Installs: 2 093

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:project

v0.0.5 2024-10-09 07:14 UTC

This package is auto-updated.

Last update: 2024-12-09 07:41:23 UTC


README

Build Status

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.