Skip to content

Commit 5bf1398

Browse files
committed
clear services cache command
1 parent 06d8caa commit 5bf1398

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/Commands/ClearServicesCache.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Inovector\Mixpost\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Inovector\Mixpost\Facades\Services;
7+
8+
class ClearServicesCache extends Command
9+
{
10+
public $signature = 'mixpost:clear-services-cache';
11+
12+
public $description = 'Clear the services from cache';
13+
14+
public function handle(): int
15+
{
16+
Services::forgetAll();
17+
18+
$this->info('Cache services has been cleared!');
19+
20+
return self::SUCCESS;
21+
}
22+
}

src/MixpostServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Debug\ExceptionHandler;
66
use Illuminate\Support\Facades\Gate;
7+
use Inovector\Mixpost\Commands\ClearServicesCache;
78
use Inovector\Mixpost\Commands\ClearSettingsCache;
89
use Inovector\Mixpost\Commands\CreateMastodonApp;
910
use Inovector\Mixpost\Commands\DeleteOldData;
@@ -50,6 +51,7 @@ public function configurePackage(Package $package): void
5051
PublishAssetsCommand::class,
5152
CreateMastodonApp::class,
5253
ClearSettingsCache::class,
54+
ClearServicesCache::class,
5355
RunScheduledPosts::class,
5456
ImportAccountAudience::class,
5557
ImportAccountData::class,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
use Inovector\Mixpost\Commands\ClearServicesCache;
4+
use Inovector\Mixpost\Facades\Services;
5+
6+
it('will clear services cache', function () {
7+
Services::put('facebook', ['client_id' => '123', 'client_secret' => '456']);
8+
Services::put('twitter', ['client_id' => '11111', 'client_secret' => '22222', 'tier' => 'free']);
9+
10+
$this->artisan(ClearServicesCache::class)->assertExitCode(0);
11+
12+
expect(Services::getFromCache('facebook'))->toBeNull()
13+
->and(Services::getFromCache('tiktok'))->toBeNull();
14+
});

0 commit comments

Comments
 (0)