Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: cache team settings

Andras Bacsai45b597bbab73
diff --git a/app/Http/Livewire/Boarding/Index.php b/app/Http/Livewire/Boarding/Index.php
index 35f7fd2180..c68cd8a506 100644
--- a/app/Http/Livewire/Boarding/Index.php
+++ b/app/Http/Livewire/Boarding/Index.php
@@ -6,6 +6,7 @@ use App\Actions\Server\InstallDocker;
use App\Models\PrivateKey;
use App\Models\Project;
use App\Models\Server;
+use App\Models\Team;
use Illuminate\Support\Collection;
use Livewire\Component;
@@ -70,9 +71,10 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
}
public function skipBoarding()
{
- currentTeam()->update([
+ Team::find(currentTeam()->id)->update([
'show_boarding' => false
]);
+ ray(currentTeam());
refreshSession();
return redirect()->route('dashboard');
}
diff --git a/app/Http/Livewire/SwitchTeam.php b/app/Http/Livewire/SwitchTeam.php
index 087a7ad84c..9a9b4c7959 100644
--- a/app/Http/Livewire/SwitchTeam.php
+++ b/app/Http/Livewire/SwitchTeam.php
@@ -23,7 +23,7 @@ class SwitchTeam extends Component
if (!$team_to_switch_to) {
return;
}
- session(['currentTeam' => $team_to_switch_to]);
+ refreshSession($team_to_switch_to);
return redirect(request()->header('Referer'));
}
}
diff --git a/app/Http/Middleware/IsBoardingFlow.php b/app/Http/Middleware/IsBoardingFlow.php
index 5858fe1918..e0542a57a9 100644
--- a/app/Http/Middleware/IsBoardingFlow.php
+++ b/app/Http/Middleware/IsBoardingFlow.php
@@ -15,7 +15,7 @@ class IsBoardingFlow
*/
public function handle(Request $request, Closure $next): Response
{
- // ray()->showQueries()->color('orange');
+ ray()->showQueries()->color('orange');
if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
return redirect('boarding');
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 9050de2140..1671db496d 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -4,6 +4,7 @@ namespace App\Models;
use App\Notifications\Channels\SendsEmail;
use App\Notifications\TransactionalEmails\ResetPassword as TransactionalEmailsResetPassword;
+use Cache;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@@ -94,7 +95,9 @@ class User extends Authenticatable implements SendsEmail
public function currentTeam()
{
- return Team::find(session('currentTeam')->id);
+ return Cache::remember('team:' . auth()->user()->id, 3600, function() {
+ return Team::find(session('currentTeam')->id);
+ });
}
public function otherTeams()
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 1616753016..7a8c5429bc 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -57,9 +57,15 @@ function showBoarding(): bool
{
return currentTeam()->show_boarding ?? false;
}
-function refreshSession(): void
+function refreshSession(?Team $team = null): void
{
- $team = Team::find(currentTeam()->id);
+ if (!$team) {
+ $team = Team::find(currentTeam()->id);
+ }
+ Cache::forget('team:' . auth()->user()->id);
+ Cache::remember('team:' . auth()->user()->id, 3600, function() use ($team) {
+ return $team;
+ });
session(['currentTeam' => $team]);
}
function general_error_handler(Throwable | null $err = null, $that = null, $isJson = false, $customErrorMessage = null): mixed