is there a way to share in-memory caching between two .Net Core Web APIs

biprism 46 Reputation points
2022-09-11T17:37:43.61+00:00

My application right now needs to cache small amount of referenced data, but various data.
Thinking of using in-memory Cache instead of REDIS or NCache. I hope this is a good decision.

If I go with in-memory Cache and implement it, is it possible to share the cache between two APIs?

For example,
First Core Web API, say CacheService uses in-memory cache to get the data cached. this Cache service is called very much at the beginning of the start of the application.
As users go through the application and request various type of data using other services say AP#1, API #2, I want these services rather than going to the database source they access the cache created by the Cacheservice at the beginning and get the data.

Or do I have to implement IMemoryCache in each of the APIs (API#1, API#2, etc)?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,382 questions
{count} votes