Skip to content

Commit

Permalink
Cache DB lookup calls
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Mar 26, 2024
1 parent 3d9cdd1 commit 33a8666
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions posthog/rbac/user_access_control.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from functools import cached_property
from functools import cached_property, cache
from django.db.models import Model, Q, QuerySet
from rest_framework import serializers
from typing import TYPE_CHECKING, List, Optional, cast
Expand Down Expand Up @@ -96,7 +96,7 @@ def access_controls_supported(self) -> bool:
AvailableFeature.PROJECT_BASED_PERMISSIONING
) or self._organization.is_feature_available(AvailableFeature.ADVANCED_PERMISSIONS)

# @cached_property
@cache
def _access_controls_for_object(self, obj: Model, resource: str) -> List[_AccessControl]:
"""
Used when checking an individual object - gets all access controls for the object and its type
Expand Down Expand Up @@ -124,7 +124,7 @@ def _access_controls_for_object(self, obj: Model, resource: str) -> List[_Access
)
)

# @cached_property
@cache
def _access_controls_for_resource(self, resource: APIScopeObject) -> List[_AccessControl]:
"""
Used when checking an individual object - gets all access controls for the object and its type
Expand Down

0 comments on commit 33a8666

Please sign in to comment.