I am trying to use see if i can update a cached collection (in memory) using HybridCache.
When using MemoryCache, I can do something like this, this was an easy “hack” to update collection without removing it from memory:
<code>var list1 = new List<string>() { "a", "b", "c" };
IMemoryCache cache = new MemoryCache(new MemoryCacheOptions());
cache.Set("Key", list1);
if (cache.TryGetValue<List<string>>("Key", out List<string>? result))
{
result!.Add("d");
}
var list = cache.Get("Key");
</code>
<code>var list1 = new List<string>() { "a", "b", "c" };
IMemoryCache cache = new MemoryCache(new MemoryCacheOptions());
cache.Set("Key", list1);
if (cache.TryGetValue<List<string>>("Key", out List<string>? result))
{
result!.Add("d");
}
var list = cache.Get("Key");
</code>
var list1 = new List<string>() { "a", "b", "c" };
IMemoryCache cache = new MemoryCache(new MemoryCacheOptions());
cache.Set("Key", list1);
if (cache.TryGetValue<List<string>>("Key", out List<string>? result))
{
result!.Add("d");
}
var list = cache.Get("Key");