21 lines
495 B
PHP
21 lines
495 B
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Services;
|
|
|
|
class UpstreamQueryCacheFactory
|
|
{
|
|
/** @var array<string,UpstreamQueryCache> */
|
|
private array $instances = [];
|
|
|
|
public function __construct(private readonly UpstreamSourceRegistry $sources)
|
|
{
|
|
}
|
|
|
|
public function forSource(string $source): UpstreamQueryCache
|
|
{
|
|
$key = $this->sources->definition($source)['key'];
|
|
|
|
return $this->instances[$key] ??= new UpstreamQueryCache($this->sources, $key);
|
|
}
|
|
}
|