MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.34k stars 457 forks source link

MemoryCacheExtensions.RegisterChild() MAY be issue with the code #245

Closed shah-keyur closed 6 years ago

shah-keyur commented 6 years ago

Hi MichaMo,

I am trying to use the CacheManager.Microsoft.Extensions.Caching.Memory.

I found that the code for MemoryCacheExtensions.RegisterChild() is inappropriate or I could not understand.

internal static void RegisterChild(this MemoryCache cache, object parentKey, object childKey) { if (cache.TryGetValue(parentKey, out var temp)) { var set = (HashSet)temp; set.Add(childKey); } }

Variable "set" is not used with "cache" seems RegisterChild() method will be just called but will not do anything.

Can you explain what it does and how it maintains the region in - memory?

Thanks, Keyur

shah-keyur commented 6 years ago

Hi MichaMo,

I feel like the method would be similar to below, correct me if I am wrong.

internal static void RegisterChild(this MemoryCache cache, object parentKey, object childKey) { if (cache.TryGetValue(parentKey, out var temp)) { var set = (HashSet)temp; set.Add(childKey); cache.Set(parentKey, set); // missing this line } } Thanks, Keyur

shah-keyur commented 6 years ago

Ignore this I got it . its reference type so no need.

my bad !