Skip to content

Commit a1a2d74

Browse files
committed
refactor: Simplify permission loading logic to enhance concurrency handling
1 parent 76a6dd2 commit a1a2d74

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/PermissionRegistrar.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,24 +207,16 @@ private function loadPermissions(): void
207207
// Another thread is loading, wait and retry
208208
usleep(10000); // Wait 10ms
209209

210-
// Recursive retry with loaded permissions check
211-
if ($this->permissions) {
212-
return;
213-
}
210+
// After wait, recursively check again if permissions were loaded
211+
$this->loadPermissions();
214212

215-
// If still not loaded after wait, proceed normally
216-
// The cache->remember() will handle cache-level locking
213+
return;
217214
}
218215

219216
// Set loading flag to prevent concurrent loads
220217
$this->isLoadingPermissions = true;
221218

222219
try {
223-
// Double-check after acquiring lock
224-
if ($this->permissions) {
225-
return;
226-
}
227-
228220
$this->permissions = $this->cache->remember(
229221
$this->cacheKey, $this->cacheExpirationTime, fn () => $this->getSerializedPermissionsForCache()
230222
);

0 commit comments

Comments
 (0)