3

Is there an alternative for Google Guava's LoadingCache in C# ?

.Net language features and external dlls will do it.

Etienne Neveu
  • 12,604
  • 9
  • 36
  • 59
Roman
  • 7,933
  • 17
  • 56
  • 72

2 Answers2

2

The MemoryCache class is one option - http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.aspx

You can set expiration policies and memory limits, I'm not sure if it encompasses all of the features of LoadingCache but it's probably close.

EkoostikMartin
  • 6,831
  • 2
  • 33
  • 62
  • 3
    Lol, 2021 year and dotnet community still don't made any cache library. Everybody relies on stock implementation with inconvenient API. – Bogdan Mart Apr 20 '21 at 06:28
  • @BogdanMart yep still nothing like Guava `LoadingCache` which handles concurrent loads. What a shame. – wilmol Dec 13 '22 at 00:06
  • My work around is a `ConcurrentDictionary>` https://stackoverflow.com/a/47489603/6122976 – wilmol Jul 07 '23 at 02:41
0

You can also use the postsharp caching.

Sample here.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
objMihail
  • 147
  • 1
  • 1
  • 7