Skip to content

Commit e1f1472

Browse files
committed
fix: support github service without cache tags
1 parent 5ca0cf6 commit e1f1472

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
includes:
2+
- vendor/larastan/larastan/extension.neon
23
- phpstan-baseline.neon
34

45
parameters:
@@ -9,4 +10,3 @@ parameters:
910
tmpDir: build/phpstan
1011
checkOctaneCompatibility: true
1112
checkModelProperties: true
12-

src/Services/GitHubService.php

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ public function getLatestTag(?string $repository = null): string
7373
$repository = $repository ?? $this->repository;
7474
$cacheKey = "filament-easy-footer.github.{$repository}.latest-tag";
7575

76-
return Cache::remember(
77-
$cacheKey,
78-
$this->cacheTtl,
79-
fn () => $this->fetchLatestTag($repository) ?? $this->defaultVersion
80-
);
76+
$cachedTag = $this->getCacheWithoutTags($cacheKey);
77+
if ($cachedTag !== null) {
78+
return $cachedTag;
79+
}
80+
81+
$tag = $this->fetchLatestTag($repository) ?? $this->defaultVersion;
82+
83+
$this->setCacheWithoutTags($cacheKey, $tag, $this->cacheTtl);
84+
85+
return $tag;
8186
}
8287

8388
protected function fetchLatestTag(string $repository): ?string
@@ -103,4 +108,23 @@ protected function fetchLatestTag(string $repository): ?string
103108

104109
return null;
105110
}
111+
112+
protected function getCacheWithoutTags(string $key)
113+
{
114+
try {
115+
return Cache::store(config('cache.default'))->get($key);
116+
} catch (\Exception $e) {
117+
report($e);
118+
return null;
119+
}
120+
}
121+
122+
protected function setCacheWithoutTags(string $key, $value, int $ttl): void
123+
{
124+
try {
125+
Cache::store(config('cache.default'))->put($key, $value, $ttl);
126+
} catch (\Exception $e) {
127+
report($e);
128+
}
129+
}
106130
}

0 commit comments

Comments
 (0)