CaiWuXiTong/modules/EcommerceFinance/Services/OperationsReplicaSnapshotRefresher.php

38 lines
1023 B
PHP

<?php
namespace Modules\EcommerceFinance\Services;
use App\Business\UpstreamBusinessInformation;
use Modules\EcommerceFinance\Contracts\UpstreamSnapshotRefresher;
/**
* 将经营分析副本库已登记的业务信息查询还原为共享快照刷新任务。
*/
class OperationsReplicaSnapshotRefresher implements UpstreamSnapshotRefresher
{
private const SOURCE = 'operations_replica';
public function __construct(
private readonly UpstreamQueryCacheFactory $caches,
private readonly UpstreamBusinessInformation $information,
) {
}
public function sourceKey(): string
{
return self::SOURCE;
}
public function refresh(array $entry): string
{
$scope = (string) ($entry['scope'] ?? '');
$parameters = (array) ($entry['parameters'] ?? []);
return $this->caches->forSource(self::SOURCE)->refresh(
$scope,
$parameters,
fn () => $this->information->snapshot($scope, $parameters),
);
}
}