-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Feat/add cache to permissions #9003
Conversation
no more progress in this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@encode/django-rest-framework Should we consider the caching of permissions by principle?
Caching with a simple If a cache should be used it should avoid this kind of problems. This implementation however does not resolve the real issue since the permission classes are instantiated twice due to how django-rest-framework/rest_framework/views.py Lines 274 to 278 in 4f7e9ed
django-rest-framework/rest_framework/views.py Lines 326 to 350 in 4f7e9ed
Thus, this kind of LRU is only going to waste memory and slow down the program. I agree that #7522 may cause some problems, also because the behaviour is not so intuitive and is only documented in the changelog and not on the permissions API reference. |
Hello there! |
Short: We shouldn't be making functional changes to REST framework now, other than tracking new Django releases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to close this for now. i think this can be done as per projects need/customised.
Description
Add new base class for permissions to cache result of
has_permission
and 'has_object_permission' methods to prevent multi call in some senarios.refs #8987