[Task]: Implement Redis caching for tenant configuration #33083
Description
Description
The tenants/current api is the slowest component of consolidated/view api. Reducing the latency of tenants/current api will reduce the latency of backend in view experience for all users.
Relevant Slack thread : https://theappsmith.slack.com/archives/C024GUDM0LT/p1713933688987279
In the diagram in the slack thread, the blue line just below the magenta line at the top is the contribution of tenants/current to consolidated api. The diagram shows that tenants/current is 90% contributor to consolidated view api.
Upon debugging the cause of latency from tenants/current, it is found that the api makes a DB call to fetch the tenant configuration every time.
Caching the tenant config ID is already present in the codebase. Extending that approach, we can cache the whole tenant config and update it when a user changes admin settings.
Not making the DB call will reduce the latency of tenants/current api and decrease the latency of consolidated view api as well.
CE PR: #33641
Counterpart EE PR: https://github.com/appsmithorg/appsmith-ee/pull/4275
Subtasks
- Implement caching for fetching tenant configuration
- Invalidate cache if tenant configuration gets updated, update the database and rebuild cache.