I am working on a project in which I will be calling Service Fabric methods and returning the data to end user. The Data is modified very infrequently or is almost constant so I want to maintain a cache and return it if the data is not modified.
The project structure is: WepApi(Stateless Service) -> Repository -> SatefulService
What is the best way of implementing this in Azure Service Fabric? I am thinking of two options:
- Redis cache a. Creating a Redis cache project where it will expose two endpoints for storing and getting cache data. This project will be referenced in the repository layer. b. Creating a Redis cache service( service fabric ) and calling from the repository.
- stateful service a. Creating a separate dictionary in the existing stateful service and use it for getting and storing data.
And, I am also having below questions.
Approach #1:
- We have to depend on 3rd party system(Redis cache) and we might not get accurate results if the server is not available.
Approach #2:
- We might get a performance issue if the cache data is increased over time.
Any best approaches to implement a cache in service fabric?
Thanks,