Skip to content

Commit

Permalink
Merge pull request #3 from pyama86/before-delete
Browse files Browse the repository at this point in the history
delete cache before send
  • Loading branch information
pyama86 committed Sep 13, 2023
2 parents 7c1a534 + 5d7f71e commit 7c1fd4a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Metrics/DefaultMetricsHandler.php
Expand Up @@ -58,16 +58,14 @@ private function shouldSend($bucket)

private function send($bucket)
{
$bucket->setEndDate(new DateTimeImmutable());
$this->metricsSender->sendMetrics($bucket);
$cache = $this->config->getCache();
try {
if ($cache->has(CacheKey::METRICS_BUCKET)) {
$cache->delete(CacheKey::METRICS_BUCKET);
}
$cache->delete(CacheKey::METRICS_BUCKET);
} catch (\Exception $e) {
error_log('Failed to delete metrics bucket: ' . $e->getMessage());
}
$bucket->setEndDate(new DateTimeImmutable());
$this->metricsSender->sendMetrics($bucket);
}

private function store($bucket)
Expand Down

0 comments on commit 7c1fd4a

Please sign in to comment.