-
Notifications
You must be signed in to change notification settings - Fork 34
Cache Builders
Alex Peck edited this page Sep 18, 2022
·
12 revisions
All cache features come with a small amount of overhead. Performance matters. Therefore, everything is disabled by default to provide maximum performance. The programmer can choose only what is needed to solve the problem at hand, without any unwanted tax.
Builders are provided for both ConcurrentLru and ConcurrentLfu to make it easy to configure more advanced caches with the requisite features.
For example, this is how to create a ConcurrentLru
with scoped values, and GetOrAdd
that is both async and has atomic value creation:
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithAtomicGetOrAdd()
.AsScopedCache()
.AsAsyncCache()
.WithCapacity(3)
.Build();