Refactor ListMemberApi to reduce number of queries made to databse.
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:
- List all parent group of the caller ------> cached
- Check if the requested group exist
- Check if the caller is the owner of the requested group
- Check if users.data.root group exist
- Check if the caller is the owner of users.data.root
- Check if the caller is a member of users.data.root
- List the member of the requested group
After this refactor, the new work flow makes the following calls to database in worst case scenario:
- List all parent group of the caller ------> cached
- Check if the requested group exist
- Check if the caller is the owner of the requested group
- 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:
- Check if the requested group exist
- Check if the caller is the owner of the requested group
- List the member of the requested group
After this refactor, the new work flow makes the following calls to database in best case scenario:
- 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.