Speed up QR create/update by cutting billing round-trips.
Deploy Ladill QR Plus / deploy (push) Successful in 2m2s

Create was making three sequential public HTTPS billing calls (~400ms each)
while holding a DB transaction open for image generation. Use loopback DNS
forcing, cache balances briefly, return balance from debit, regenerate images
only when style changes, and keep remote work outside the DB transaction.
This commit is contained in:
isaacclad
2026-07-16 21:25:16 +00:00
parent d83a314bee
commit 02e6778ccf
7 changed files with 261 additions and 64 deletions
@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
use App\Services\Billing\BillingClient;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
/**
* Lightweight wallet balance for the avatar dropdown widget.
@@ -16,15 +15,10 @@ class WalletBalanceController extends Controller
{
$publicId = (string) $request->user()->public_id;
$minor = Cache::remember("wallet_balance:{$publicId}", now()->addSeconds(30), function () use ($billing, $publicId) {
try {
return $billing->balanceMinor($publicId);
} catch (\Throwable) {
return null;
}
});
if ($minor === null) {
// BillingClient already short-caches balances; avoid a second long cache layer.
try {
$minor = $billing->balanceMinor($publicId);
} catch (\Throwable) {
return response()->json(['available' => false]);
}