alastairtree / LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
https://nuget.org/packages/LazyCache
MIT License
1.72k stars 159 forks source link

Add TryGetValue #142

Closed talmroth closed 3 years ago

talmroth commented 3 years ago

I actually need a Contains but since this version of MemoryCache does not have a Contains TryGetValue is the next best thing.

alastairtree commented 3 years ago

To do a contains, why not just do Get(key) != null? (Or GerAsync).

talmroth commented 3 years ago

That won’t work with value types and unfortunately I also have a use case where nulls are being cached so I need a definitive way to know if a value is cached.

dseipp commented 3 years ago

Can this be switched to out T instead of out object if that's what is being returned here?

alastairtree commented 3 years ago

Can this be switched to out T instead of out object if that's what is being returned here?

Yes that would be better! Send a PR?