Skip to content

Commit 632f2cb

Browse files
committed
Update SoftwareUpdateService, add command to refresh latest versions
1 parent b1cdf44 commit 632f2cb

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use App\Services\Internal\SoftwareUpdateService;
7+
use Cache;
8+
9+
class SoftwareUpdateRefresh extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'app:software-update-refresh';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Refresh latest software version data';
24+
25+
/**
26+
* Execute the console command.
27+
*/
28+
public function handle()
29+
{
30+
$key = SoftwareUpdateService::cacheKey();
31+
Cache::forget($key);
32+
Cache::remember($key, 1209600, function() {
33+
return SoftwareUpdateService::fetchLatest();
34+
});
35+
$this->info('Succesfully updated software versions!');
36+
}
37+
}

app/Services/Internal/SoftwareUpdateService.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ class SoftwareUpdateService
1111
{
1212
const CACHE_KEY = 'pf:services:software-update:';
1313

14+
public static function cacheKey()
15+
{
16+
return self::CACHE_KEY . 'latest:v1.0.0';
17+
}
18+
1419
public static function get()
1520
{
1621
$curVersion = config('pixelfed.version');
1722

18-
$versions = Cache::remember(self::CACHE_KEY . 'latest:v1.0.0', 1800, function() {
23+
$versions = Cache::remember(self::cacheKey(), 1800, function() {
1924
return self::fetchLatest();
2025
});
2126

0 commit comments

Comments
 (0)