Skip to content

Refactor ListMemberApi to reduce number of queries made to databse.

Yifan Ye requested to merge member-refactor into master

Refactor ListMemberApi, implementing cache for the listMemberApi and refactoring the Permission.java class to reduce the number of queries made to database. This is the fix to issue #173.

Before this change, the work flow of ListMemberApi makes the following calls to database in worst case scenario:

  1. List all parent group of the caller ------> cached
  2. Check if the requested group exist
  3. Check if the caller is the owner of the requested group
  4. Check if users.data.root group exist
  5. Check if the caller is the owner of users.data.root
  6. Check if the caller is a member of users.data.root
  7. List the member of the requested group

After this refactor, the new work flow makes the following calls to database in worst case scenario:

  1. List all parent group of the caller ------> cached
  2. Check if the requested group exist
  3. Check if the caller is the owner of the requested group
  4. List the member of the requested group -----> new cache implemented

This reduce the request unit in worst case scenario from 56RU to 33RU

Before this change, the work flow of ListMemberApi makes the following calls to database in best case scenario:

  1. Check if the requested group exist
  2. Check if the caller is the owner of the requested group
  3. List the member of the requested group

After this refactor, the new work flow makes the following calls to database in best case scenario:

  1. Check if the requested group exist

This reduce the request unit in worst case scenario from 23RU to 3RU

With this refactor, the members of the group will be cached for later usage and the API no longer makes 3 calls to the database to check if the caller belongs to users.data.root.

Edited by Yifan Ye

Merge request reports

Loading