Issue:
feat: add caching for roles

Currently in authorization, we look at the resource and the role in the JWT to check whether that particular call is valid or not.

Upon the introduction of custom roles, this has increased db calls in the authorization phase as we need to get the permissions associated to a particular role. This will have unnecessary load on db and hits the performance of every api call.

To fix this, redis needs to be used to cache the permissions for a custom role.

Resolution:
<think>
PR Context:
- Title: feat(roles): Add caching for custom roles
- Merged: 2024-03-05T13:40:13Z
- Files changed: 12 files
- Commits: 9 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
This PR will add caching for custom roles to reduce db calls and improve efficiency.

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configura
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(roles): Add caching for custom roles (#3946)
Files to modify:


**crates/api_models/src/user.rs**
  Modify existing code

**crates/api_models/src/user_role.rs**
  Modify existing code

**crates/router/src/consts.rs**
  Modify existing code

**crates/router/src/core/user.rs**
  Modify existing code

**crates/router/src/core/user_role.rs**
  Modify existing code

**crates/router/src/services/authentication/blacklist.rs**
  Add:
    - function: private::invalidate_role_cache

**crates/router/src/services/authorization.rs**
  Add:
    - function: private::get_permissions_from_cache
    - function: pub::get_cache_key_from_role_id
    - function: private::get_permissions_from_predefined_roles
    - function: private::get_permissions_from_db
    - function: private::get_redis_connection

**crates/router/src/services/authorization/info.rs**
  Modify existing code

**crates/router/src/services/authorization/permissions.rs**
  Modify existing code

**crates/router/src/types/domain/user.rs**
  Modify existing code

**crates/router/src/utils/user.rs**
  Modify existing code

**crates/router/src/utils/user_role.rs**
  Add:
    - function: pub::set_role_permissions_in_cache_by_user_role
    - function: pub::set_role_permissions_in_cache_if_required