// cache Cache::remember('tenant_' . $id, 3600, fn() => QueryBuilder::table('tenants')::where('id', $id)::fetchOne() ); // rate limiting with Redis increment $key = 'login_attempts_' . $_SERVER['REMOTE_ADDR']; $attempts = Cache::increment($key); if ($attempts === 1) Cache::expire($key, 900); if ($attempts > 5) { Response::simple(true, 'Too many attempts. Try again in 15 minutes.', 429); return; } // invalidate a group of keys Cache::deletePattern('tenant_*'); // health check endpoint JsonBuilder::init()::data(Cache::stats())::send(); // mailer — identical usage, now goes via Mailgun Mailer::send($provider, $user['email'], 'welcome', ['name' => $user['name']]); // scheduled email Mailer::sendAt( $user['email'], 'promo-launch', ['name' => $user['name'], 'promo' => '20% off'], '2026-06-01 08:00:00' // UTC — sends at 8AM UTC on June 1 ); /* 1. Invalidate on write (recommended) Whenever you update, insert, or delete a row in the database, also clear the corresponding cache key(s). */ // Example: update tenant record QueryBuilder::table('tenants')::where('id', $id)::update($data); // Invalidate cache for that tenant Cache::delete('tenant_' . $id);