-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache performance inefficent #600
Comments
|
That's one way of doing it, though would mean a lot more keys being set in Redis: users * abilities = quite lot of keys of bools. Personally I think permissions is such an integral part of an application it makes sense to just have a field directly on the User model... $user->permissions which is a JSON array of the users roles, and abilities cached. That JSON array would be super simple which lists roles, and individual granted abilities, e.g: $user->permissions: {"roles": ["moderator", "editor"], "granted": ["kick-users"], "forbidden": ["ban-users"]} ....that way there is no need for caching, it's already available on users straight out the box. The amount of data stored is minimal, and the abilities can be loaded once and expanded based on the roles. Roles Caching by PHP File In addition to the above the abilities for each role could be cached in a PHP file, a bit like config caching, which would also benefit from OpCache. It would just be a simple file that returns:
As I write this, I'm starting to realise maybe it's sensible we create own super simple permission system |
I was about to reply, but now see that this hasn't been active since July '22 - is it still relevant? Anyhow - rather than caching the results on the users table, why not cache it in the cache? All that's changed in your proposal is that the cache is per user, rather than per user per ability. I was about to refactor my app to use Bouncer, and this post spooked me. Regarding the assertions of the original post:
|
There are various performance and storage problems with the
CachedClipboard
as below:See below example of bouncer setting cached ability in Redis:
Huge payloads set for every single user
With an application of a million users and 200 abilities Bouncer would set a HUGE amount of data in cache, forever.
I'm not sure what the solution is here, but I think reducing the payload stored would be a good start, maybe limit it to just the important ids if possible. Also is there a reason why it needs to cache for each user?
The text was updated successfully, but these errors were encountered: