39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\ManagementTools\Services\ExecutiveCockpit;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class CockpitMetricsCache
|
|
{
|
|
public function rememberKpis(int $businessId, Carbon $startDate, Carbon $endDate, callable $resolver): array
|
|
{
|
|
$key = sprintf(
|
|
'cockpit:kpis:%d:%s:%s',
|
|
$businessId,
|
|
$startDate->toDateString(),
|
|
$endDate->toDateString()
|
|
);
|
|
|
|
return Cache::remember($key, 300, $resolver);
|
|
}
|
|
|
|
public function rememberHoldingComparison(int $businessId, Carbon $startDate, Carbon $endDate, callable $resolver): array
|
|
{
|
|
$key = sprintf(
|
|
'cockpit:holding:%d:%s:%s',
|
|
$businessId,
|
|
$startDate->toDateString(),
|
|
$endDate->toDateString()
|
|
);
|
|
|
|
return Cache::remember($key, 300, $resolver);
|
|
}
|
|
|
|
public function forgetBusiness(int $businessId): void
|
|
{
|
|
// Pattern-based invalidation is driver-dependent; callers can rely on TTL.
|
|
}
|
|
}
|