Pedro, you have some options.
Distributed memory cache or cache, for example Redis.
In memorycache you can store the key/value, as the example:
protected MemoryCache cache = new MemoryCache("CachingProvider");
static readonly object padlock = new object();
protected virtual void AddItem(string key, object value)
{
lock (padlock)
{
cache.Add(key, value, DateTimeOffset.MaxValue);
}
}
protected virtual void RemoveItem(string key)
{
lock (padlock)
{
cache.Remove(key);
}
}
protected virtual object GetItem(string key, bool remove)
{
lock (padlock)
{
var res = cache[key];
if (res != null)
{
if (remove == true)
cache.Remove(key);
}
else
{
WriteToLog("CachingProvider-GetItem: Don't contains key: " + key);
}
return res;
}
}
Then it would be nice to create a cache layer in your application, when the database was changed or something like invalidated your cache and you would update it again.
I believe that for your application Memorycache already serves you, has more information where I got this code:
https://www.codeproject.com/Articles/756423/How-to-Cache-Objects-Simply-using-System-Runtime-C