Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions ProcessMaker/Jobs/RefreshArtisanCaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Support\Facades\Artisan;

class RefreshArtisanCaches implements ShouldQueue
Expand All @@ -24,6 +25,16 @@ public function __construct()
//
}

/**
* Debounce when multiple Settings are saved at the same time
*
* @return array<int, object>
*/
public function middleware(): array
{
return [(new WithoutOverlapping('refresh_artisan_caches'))->dontRelease()];
}

/**
* Execute the job.
*
Expand All @@ -38,12 +49,7 @@ public function handle()

if (app()->configurationIsCached()) {
Artisan::call('config:cache', $options);
} else {
Artisan::call('queue:restart', $options);

// We call this manually here since this job is dispatched
// automatically when the config *is* cached
RestartMessageConsumers::dispatchSync();
}
Artisan::call('queue:restart', $options);
}
}
3 changes: 3 additions & 0 deletions ProcessMaker/Observers/SettingObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Exception;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Cache\Settings\SettingCacheFactory;
use ProcessMaker\Jobs\RefreshArtisanCaches;
use ProcessMaker\Models\Setting;

class SettingObserver
Expand Down Expand Up @@ -89,5 +90,7 @@ private function invalidateSettingCache(Setting $setting)
// Invalidate the setting cache
$key = $settingCache->createKey(['key' => $setting->key]);
$settingCache->invalidate(['key' => $key]);

RefreshArtisanCaches::dispatch();
}
}
Loading