Skip to content
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

[core] Create admin cache to reduce privilege check latency #34

Open
ammarfaizi2 opened this issue Jun 4, 2021 · 0 comments
Open

[core] Create admin cache to reduce privilege check latency #34

ammarfaizi2 opened this issue Jun 4, 2021 · 0 comments
Assignees
Labels
core Core functionallity

Comments

@ammarfaizi2
Copy link
Contributor

ammarfaizi2 commented Jun 4, 2021

Calling getChatAdministrators() every time privilege check is done is too expensive w.r.t. latency.

Workaround

  • Check for privilege every message count reaches a number which is divisible by N.

Pseudo Code

if (message_count % N == 0) {
  updateAdminCache();
}


/*
 * Privilege check function
 */
bool checkPrivileged(uint64_t user_id, int64_t group_id) {
   if (checkPrivilegeFromCache(user_id, group_id)) 
      return true;
   updateAdminCache();
   return checkPrivilegeFromCache(user_id, group_id);
}
@ammarfaizi2 ammarfaizi2 self-assigned this Jun 4, 2021
@ammarfaizi2 ammarfaizi2 added the core Core functionallity label Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionallity
Projects
None yet
Development

No branches or pull requests

1 participant