Skip to content
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

performance proposal - Store data in static variable #134

Closed
arashsaffari opened this issue Nov 6, 2019 · 1 comment
Closed

performance proposal - Store data in static variable #134

arashsaffari opened this issue Nov 6, 2019 · 1 comment

Comments

@arashsaffari
Copy link

arashsaffari commented Nov 6, 2019

Each query for rights and groups sends a query to the database.

But you can save all rights and groups in a static variable at the first query and search only the variable at next query.

as an an example:
I use in a template file 6 times the function has_permission(). this function sends 2 queries to the database each time. total of 12 queries. . But you can reduce that to 1 or 2.

Thanks for your great job

@lonnieezell
Copy link
Owner

Good idea. As of 136098f I'm part of the way there.

  • User permissions are now cached using whatever cache engine is enabled at the PermissionModel level. Helps in several calls from FlatAuthorization.
  • The User entity now stores user permissions (both user-specific and from their groups) in the entity to restrict that database call to once anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants