Browse Source

perf: 优化 UserPermTreeExprireUtil

pull/9212/head
Bai 2 years ago committed by Jiangjie.Bai
parent
commit
5e5061a825
  1. 15
      apps/perms/utils/user_permission.py

15
apps/perms/utils/user_permission.py

@ -114,13 +114,6 @@ class UserPermTreeExpireUtil(UserPermTreeCacheMixin):
def cache_key_all_user(self):
return self.get_cache_key('*')
def expire_perm_tree_for_all_user(self):
keys = self.client.keys(self.cache_key_all_user)
with self.client.pipline() as p:
for k in keys:
p.delete(k)
p.execute()
def expire_perm_tree_for_nodes_assets(self, node_ids, asset_ids):
node_perm_ids = AssetPermissionUtil().get_permissions_for_nodes(node_ids, flat=True)
asset_perm_ids = AssetPermissionUtil().get_permissions_for_assets(asset_ids, flat=True)
@ -158,6 +151,14 @@ class UserPermTreeExpireUtil(UserPermTreeCacheMixin):
p.execute()
logger.info('Expire perm tree for users: [{}], orgs: [{}]'.format(user_ids, org_ids))
def expire_perm_tree_for_all_user(self):
keys = self.client.keys(self.cache_key_all_user)
with self.client.pipline() as p:
for k in keys:
p.delete(k)
p.execute()
logger.info('Expire all user perm tree')
class UserGrantedUtilsBase:
user: User

Loading…
Cancel
Save