onQueue((string) config('nntmux.api.audit_queue', 'api-audit')); } public function handle(): void { UserRequest::query()->insert([ 'users_id' => $this->userId, 'request' => $this->requestUri, 'timestamp' => $this->occurredAt, ]); $lockKey = 'api_access_update:'.$this->userId; $interval = max(1, (int) config('nntmux.api.access_update_interval', 60)); try { if (! Cache::add($lockKey, true, $interval)) { return; } } catch (Throwable) { // Cache degradation must not retry and duplicate the durable audit row. } $update = ['apiaccess' => $this->occurredAt]; if ($this->ip !== null) { $update['host'] = $this->ip; } DB::table('users')->where('id', $this->userId)->update($update); } }