roles icon indicating copy to clipboard operation
roles copied to clipboard

Performance issues from always reading roles from cache

Open jcart opened this issue 4 years ago • 0 comments

Using this package that relies strictly on external cache to retrieve the roles, even after they have been retrieved from cache from previous calls.

This negates any possibility of eagerly loading the data from an initial query, in cases where collections are returned, which is very important.

$user = User::with('roles')-get();
$user->hasRole( .. );
$user->hasRole( .. );

This results in 2 cache retrievals from your external cache.

We have in some cases some complex permission schemes within a collection, which results in hundreds of calls to Redis.

An older version of the application does not suffer from this issue, but I'm not clear why you opt'd to always visit the external cache over in memory. See https://github.com/httpoz/roles/commit/4860bc04cbee827e417dc668d75150e44637e55a

jcart avatar Jul 29 '21 19:07 jcart