phpyh/lru-memoizer

PHPyh LRU Memoizer

0.2.0 2023-02-25 04:45 UTC

This package is auto-updated.

Last update: 2024-10-21 07:31:36 UTC


README

Installation

composer require phpyh/lru-memoizer

Usage

use PHPyh\LRUMemoizer\LRUMemoizer;

final class Metadata {}

final class MetadataFactory
{
    public function __construct(
        private readonly LRUMemoizer $memoizer = new LRUMemoizer(capacity: 25),
    ) {
    }

    /**
     * @param ?class-string $class
     */
    public function metadataFor(string $class): Metadata
    {
        return $this->memoizer->get($class, static fn (): Metadata => new Metadata());
    }
}