I am creating a business proxy to add more request restriction (because the target API does not provide a fine RBAC).
To realize this program, I use the YARP extension to have a default proxy and I add a lot of middleware to have restrictions / validations of user request.
In order to create restriction classes, I need to retrieve the configuration stored in the database. and I would like to avoid making direct requests to the database (because this product can receive 1M requests per hour).
The following image is a simple implementation of the database for the necessary configuration: simple database
How would you get this data into a singletons middleware with following restriction:
- Avoid creating transitive or scoped services to improve program performance.
- Limit usage of the
IServiceScopeFactory
to retrieve data from database. - Can use distributed cache (Redis implementation)