Skip to content

Commit 5543be0

Browse files
committed
Cache changelog for a week
1 parent 2349a82 commit 5543be0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ux.symfony.com/src/Service/Changelog/ChangelogProvider.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Contracts\Cache\CacheInterface;
1616
use Symfony\Contracts\HttpClient\HttpClientInterface;
1717

18+
/**
19+
* @internal
20+
*/
1821
final class ChangelogProvider
1922
{
2023
public function __construct(
@@ -27,26 +30,28 @@ public function getChangelog(int $page = 1): array
2730
{
2831
$changelog = [];
2932

30-
foreach ($this->loadReleases($page) as $release) {
33+
foreach ($this->getReleases($page) as $release) {
3134
$changelog[] = $release;
3235
}
3336

3437
return $changelog;
3538
}
3639

37-
private function loadReleases(int $page = 1): array
40+
private function getReleases(int $page = 1): array
3841
{
3942
return $this->cache->get('releases-symfony-ux-'.$page, function (CacheItemInterface $item) use ($page) {
40-
$item->expiresAfter(3600);
43+
$item->expiresAfter(604800); // 1 week
4144

42-
return $this->getReleases('symfony', 'ux', $page);
45+
return $this->fetchReleases('symfony', 'ux', $page);
4346
});
4447
}
4548

4649
/**
4750
* @return array<int, array{id: int, name: string, version: string, date: string, body: string}>
51+
*
52+
* @internal
4853
*/
49-
public function getReleases(string $owner, string $repo, int $page = 1, int $perPage = 20): array
54+
private function fetchReleases(string $owner, string $repo, int $page = 1, int $perPage = 20): array
5055
{
5156
$response = $this->httpClient->request('GET', sprintf('https://api.github.com/repos/%s/%s/releases', $owner, $repo), [
5257
'query' => [

0 commit comments

Comments
 (0)