diff --git a/BitFaster.Caching.Benchmarks/Lru/LruAsyncGet.cs b/BitFaster.Caching.Benchmarks/Lru/LruAsyncGet.cs index 02742ee1..50677f18 100644 --- a/BitFaster.Caching.Benchmarks/Lru/LruAsyncGet.cs +++ b/BitFaster.Caching.Benchmarks/Lru/LruAsyncGet.cs @@ -20,7 +20,7 @@ public class LruAsyncGet { // if the cache value is a value type, value task has no effect - so use string to repro. private static readonly IAsyncCache concurrentLru = new ConcurrentLruBuilder().AsAsyncCache().Build(); - private static readonly IAsyncCache atomicConcurrentLru = new ConcurrentLruBuilder().AsAsyncCache().WithAtomicCreate().Build(); + private static readonly IAsyncCache atomicConcurrentLru = new ConcurrentLruBuilder().AsAsyncCache().WithAtomicValueFactory().Build(); private static Task returnTask = Task.FromResult("1"); diff --git a/BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs b/BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs index d7a90a91..7d71d992 100644 --- a/BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs +++ b/BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs @@ -44,7 +44,7 @@ public class LruJustGetOrAdd private static readonly FastConcurrentLru fastConcurrentLru = new FastConcurrentLru(8, 9, EqualityComparer.Default); private static readonly FastConcurrentTLru fastConcurrentTLru = new FastConcurrentTLru(8, 9, EqualityComparer.Default, TimeSpan.FromMinutes(1)); - private static readonly ICache atomicFastLru = new ConcurrentLruBuilder().WithConcurrencyLevel(8).WithCapacity(9).WithAtomicCreate().Build(); + private static readonly ICache atomicFastLru = new ConcurrentLruBuilder().WithConcurrencyLevel(8).WithCapacity(9).WithAtomicValueFactory().Build(); private static readonly int key = 1; private static System.Runtime.Caching.MemoryCache memoryCache = System.Runtime.Caching.MemoryCache.Default; diff --git a/BitFaster.Caching.UnitTests/Lru/ConcurrentLruBuilderTests.cs b/BitFaster.Caching.UnitTests/Lru/ConcurrentLruBuilderTests.cs index 9ffa9a59..c8920345 100644 --- a/BitFaster.Caching.UnitTests/Lru/ConcurrentLruBuilderTests.cs +++ b/BitFaster.Caching.UnitTests/Lru/ConcurrentLruBuilderTests.cs @@ -196,7 +196,7 @@ public void TestPartitionCapacity() public void WithScopedValues() { IScopedCache lru = new ConcurrentLruBuilder() - .WithScopedValues() + .AsScopedCache() .WithCapacity(3) .Build(); @@ -209,7 +209,7 @@ public void WithScopedValues() public void WithAtomicFactory() { ICache lru = new ConcurrentLruBuilder() - .WithAtomicCreate() + .WithAtomicValueFactory() .WithCapacity(3) .Build(); @@ -233,8 +233,8 @@ public void AsAsync() public void WithAtomicWithScope() { IScopedCache lru = new ConcurrentLruBuilder() - .WithAtomicCreate() - .WithScopedValues() + .WithAtomicValueFactory() + .AsScopedCache() .WithCapacity(3) .Build(); @@ -247,8 +247,8 @@ public void WithAtomicWithScope() public void WithScopedWithAtomic() { IScopedCache lru = new ConcurrentLruBuilder() - .WithScopedValues() - .WithAtomicCreate() + .AsScopedCache() + .WithAtomicValueFactory() .WithCapacity(3) .Build(); @@ -262,7 +262,7 @@ public void AsAsyncWithScoped() { IScopedAsyncCache lru = new ConcurrentLruBuilder() .AsAsyncCache() - .WithScopedValues() + .AsScopedCache() .WithCapacity(3) .Build(); @@ -276,7 +276,7 @@ public void AsAsyncWithScoped() public void WithScopedAsAsync() { IScopedAsyncCache lru = new ConcurrentLruBuilder() - .WithScopedValues() + .AsScopedCache() .AsAsyncCache() .WithCapacity(3) .Build(); @@ -290,7 +290,7 @@ public void WithScopedAsAsync() public void WithAtomicAsAsync() { IAsyncCache lru = new ConcurrentLruBuilder() - .WithAtomicCreate() + .WithAtomicValueFactory() .AsAsyncCache() .WithCapacity(3) .Build(); @@ -304,7 +304,7 @@ public void AsAsyncWithAtomic() { IAsyncCache lru = new ConcurrentLruBuilder() .AsAsyncCache() - .WithAtomicCreate() + .WithAtomicValueFactory() .WithCapacity(3) .Build(); @@ -315,11 +315,9 @@ public void AsAsyncWithAtomic() [Fact] public void WithAtomicWithScopedAsAsync() { - // TODO: this will not resolve a TLru - IScopedAsyncCache lru = new ConcurrentLruBuilder() - .WithAtomicCreate() - .WithScopedValues() + .WithAtomicValueFactory() + .AsScopedCache() .AsAsyncCache() .WithCapacity(3) .Build(); @@ -331,12 +329,10 @@ public void WithAtomicWithScopedAsAsync() [Fact] public void WithAtomicAsAsyncWithScoped() { - // TODO: this will not resolve a TLru - IScopedAsyncCache lru = new ConcurrentLruBuilder() - .WithAtomicCreate() + .WithAtomicValueFactory() .AsAsyncCache() - .WithScopedValues() + .AsScopedCache() .WithCapacity(3) .Build(); @@ -347,11 +343,9 @@ public void WithAtomicAsAsyncWithScoped() [Fact] public void WithScopedWithAtomicAsAsync() { - // TODO: this will not resolve a TLru - IScopedAsyncCache lru = new ConcurrentLruBuilder() - .WithScopedValues() - .WithAtomicCreate() + .AsScopedCache() + .WithAtomicValueFactory() .AsAsyncCache() .WithCapacity(3) .Build(); @@ -363,12 +357,10 @@ public void WithScopedWithAtomicAsAsync() [Fact] public void WithScopedAsAsyncWithAtomic() { - // TODO: this will not resolve a TLru - IScopedAsyncCache lru = new ConcurrentLruBuilder() - .WithScopedValues() + .AsScopedCache() .AsAsyncCache() - .WithAtomicCreate() + .WithAtomicValueFactory() .WithCapacity(3) .Build(); @@ -379,12 +371,10 @@ public void WithScopedAsAsyncWithAtomic() [Fact] public void AsAsyncWithScopedWithAtomic() { - // TODO: this will not resolve a TLru - IScopedAsyncCache lru = new ConcurrentLruBuilder() .AsAsyncCache() - .WithScopedValues() - .WithAtomicCreate() + .AsScopedCache() + .WithAtomicValueFactory() .WithCapacity(3) .Build(); @@ -395,12 +385,10 @@ public void AsAsyncWithScopedWithAtomic() [Fact] public void AsAsyncWithAtomicWithScoped() { - // TODO: this will not resolve a TLru - IScopedAsyncCache lru = new ConcurrentLruBuilder() .AsAsyncCache() - .WithAtomicCreate() - .WithScopedValues() + .WithAtomicValueFactory() + .AsScopedCache() .WithCapacity(3) .Build(); diff --git a/BitFaster.Caching/Lru/Builder/AsyncAtomicLruBuilder.cs b/BitFaster.Caching/Lru/Builder/AtomicAsyncConcurrentLruBuilder.cs similarity index 69% rename from BitFaster.Caching/Lru/Builder/AsyncAtomicLruBuilder.cs rename to BitFaster.Caching/Lru/Builder/AtomicAsyncConcurrentLruBuilder.cs index f92c26c6..601400e3 100644 --- a/BitFaster.Caching/Lru/Builder/AsyncAtomicLruBuilder.cs +++ b/BitFaster.Caching/Lru/Builder/AtomicAsyncConcurrentLruBuilder.cs @@ -7,11 +7,11 @@ namespace BitFaster.Caching.Lru.Builder { - public class AsyncAtomicLruBuilder : LruBuilderBase, IAsyncCache> + public class AtomicAsyncConcurrentLruBuilder : LruBuilderBase, IAsyncCache> { private readonly ConcurrentLruBuilder> inner; - internal AsyncAtomicLruBuilder(ConcurrentLruBuilder> inner) + internal AtomicAsyncConcurrentLruBuilder(ConcurrentLruBuilder> inner) : base(inner.info) { this.inner = inner; diff --git a/BitFaster.Caching/Lru/Builder/AtomicLruBuilder.cs b/BitFaster.Caching/Lru/Builder/AtomicConcurrentLruBuilder.cs similarity index 71% rename from BitFaster.Caching/Lru/Builder/AtomicLruBuilder.cs rename to BitFaster.Caching/Lru/Builder/AtomicConcurrentLruBuilder.cs index cc1940b5..e1b1050e 100644 --- a/BitFaster.Caching/Lru/Builder/AtomicLruBuilder.cs +++ b/BitFaster.Caching/Lru/Builder/AtomicConcurrentLruBuilder.cs @@ -7,11 +7,11 @@ namespace BitFaster.Caching.Lru.Builder { - public class AtomicLruBuilder : LruBuilderBase, ICache> + public class AtomicConcurrentLruBuilder : LruBuilderBase, ICache> { private readonly ConcurrentLruBuilder> inner; - internal AtomicLruBuilder(ConcurrentLruBuilder> inner) + internal AtomicConcurrentLruBuilder(ConcurrentLruBuilder> inner) : base(inner.info) { this.inner = inner; diff --git a/BitFaster.Caching/Lru/Builder/ScopedAsyncAtomicLruBuilder.cs b/BitFaster.Caching/Lru/Builder/AtomicScopedAsyncConcurrentLruBuilder.cs similarity index 70% rename from BitFaster.Caching/Lru/Builder/ScopedAsyncAtomicLruBuilder.cs rename to BitFaster.Caching/Lru/Builder/AtomicScopedAsyncConcurrentLruBuilder.cs index 8553f91f..316792df 100644 --- a/BitFaster.Caching/Lru/Builder/ScopedAsyncAtomicLruBuilder.cs +++ b/BitFaster.Caching/Lru/Builder/AtomicScopedAsyncConcurrentLruBuilder.cs @@ -7,11 +7,11 @@ namespace BitFaster.Caching.Lru.Builder { - public sealed class ScopedAsyncAtomicLruBuilder : LruBuilderBase, IScopedAsyncCache> where V : IDisposable + public sealed class AtomicScopedAsyncConcurrentLruBuilder : LruBuilderBase, IScopedAsyncCache> where V : IDisposable { private readonly AsyncConcurrentLruBuilder> inner; - internal ScopedAsyncAtomicLruBuilder(AsyncConcurrentLruBuilder> inner) + internal AtomicScopedAsyncConcurrentLruBuilder(AsyncConcurrentLruBuilder> inner) : base(inner.info) { this.inner = inner; diff --git a/BitFaster.Caching/Lru/Builder/ScopedAtomicLruBuilder.cs b/BitFaster.Caching/Lru/Builder/AtomicScopedConcurrentLruBuilder.cs similarity index 68% rename from BitFaster.Caching/Lru/Builder/ScopedAtomicLruBuilder.cs rename to BitFaster.Caching/Lru/Builder/AtomicScopedConcurrentLruBuilder.cs index 25b15daf..dd89bbc4 100644 --- a/BitFaster.Caching/Lru/Builder/ScopedAtomicLruBuilder.cs +++ b/BitFaster.Caching/Lru/Builder/AtomicScopedConcurrentLruBuilder.cs @@ -7,11 +7,11 @@ namespace BitFaster.Caching.Lru.Builder { - public class ScopedAtomicLruBuilder : LruBuilderBase, IScopedCache> where V : IDisposable + public class AtomicScopedConcurrentLruBuilder : LruBuilderBase, IScopedCache> where V : IDisposable { private readonly ConcurrentLruBuilder> inner; - internal ScopedAtomicLruBuilder(ConcurrentLruBuilder> inner) + internal AtomicScopedConcurrentLruBuilder(ConcurrentLruBuilder> inner) : base(inner.info) { this.inner = inner; diff --git a/BitFaster.Caching/Lru/Builder/ScopedAsyncLruBuilder.cs b/BitFaster.Caching/Lru/Builder/ScopedAsyncConcurrentLruBuilder.cs similarity index 71% rename from BitFaster.Caching/Lru/Builder/ScopedAsyncLruBuilder.cs rename to BitFaster.Caching/Lru/Builder/ScopedAsyncConcurrentLruBuilder.cs index 2b280728..f1952876 100644 --- a/BitFaster.Caching/Lru/Builder/ScopedAsyncLruBuilder.cs +++ b/BitFaster.Caching/Lru/Builder/ScopedAsyncConcurrentLruBuilder.cs @@ -6,11 +6,11 @@ namespace BitFaster.Caching.Lru.Builder { - public sealed class ScopedAsyncLruBuilder : LruBuilderBase, IScopedAsyncCache> where V : IDisposable + public sealed class ScopedAsyncConcurrentLruBuilder : LruBuilderBase, IScopedAsyncCache> where V : IDisposable { private readonly AsyncConcurrentLruBuilder> inner; - internal ScopedAsyncLruBuilder(AsyncConcurrentLruBuilder> inner) + internal ScopedAsyncConcurrentLruBuilder(AsyncConcurrentLruBuilder> inner) : base(inner.info) { this.inner = inner; diff --git a/BitFaster.Caching/Lru/Builder/ScopedLruBuilder.cs b/BitFaster.Caching/Lru/Builder/ScopedConcurrentLruBuilder.cs similarity index 71% rename from BitFaster.Caching/Lru/Builder/ScopedLruBuilder.cs rename to BitFaster.Caching/Lru/Builder/ScopedConcurrentLruBuilder.cs index 8007103a..c0fe8167 100644 --- a/BitFaster.Caching/Lru/Builder/ScopedLruBuilder.cs +++ b/BitFaster.Caching/Lru/Builder/ScopedConcurrentLruBuilder.cs @@ -7,11 +7,11 @@ namespace BitFaster.Caching.Lru.Builder { - public sealed class ScopedLruBuilder : LruBuilderBase, IScopedCache> where V : IDisposable where W : IScoped + public sealed class ScopedConcurrentLruBuilder : LruBuilderBase, IScopedCache> where V : IDisposable where W : IScoped { private readonly ConcurrentLruBuilder inner; - internal ScopedLruBuilder(ConcurrentLruBuilder inner) + internal ScopedConcurrentLruBuilder(ConcurrentLruBuilder inner) : base(inner.info) { this.inner = inner; diff --git a/BitFaster.Caching/Lru/ConcurrentLruBuilder.cs b/BitFaster.Caching/Lru/ConcurrentLruBuilder.cs index 91b3431d..57381fd1 100644 --- a/BitFaster.Caching/Lru/ConcurrentLruBuilder.cs +++ b/BitFaster.Caching/Lru/ConcurrentLruBuilder.cs @@ -24,7 +24,7 @@ namespace BitFaster.Caching.Lru public sealed class ConcurrentLruBuilder : LruBuilderBase, ICache> { /// - /// Creates a ConcurrentLruBuilder. + /// Creates a ConcurrentLruBuilder. Chain method calls onto ConcurrentLruBuilder to configure the cache then call Build to create a cache instance. /// public ConcurrentLruBuilder() : base(new LruInfo()) diff --git a/BitFaster.Caching/Lru/ConcurrentLruBuilderExtensions.cs b/BitFaster.Caching/Lru/ConcurrentLruBuilderExtensions.cs index 8805d849..a123050c 100644 --- a/BitFaster.Caching/Lru/ConcurrentLruBuilderExtensions.cs +++ b/BitFaster.Caching/Lru/ConcurrentLruBuilderExtensions.cs @@ -11,83 +11,167 @@ namespace BitFaster.Caching.Lru public static class ConcurrentLruBuilderExtensions { /// - /// Wrap IDisposable values in a lifetime scope. Scoped caches return lifetimes that prevent + /// Build an IScopedCache. IDisposable values are wrapped in a lifetime scope. Scoped caches return lifetimes that prevent /// values from being disposed until the calling code completes. /// /// The type of keys in the cache. /// The type of values in the cache. /// The ConcurrentLruBuilder to chain method calls onto. - /// A ScopedLruBuilder - public static ScopedLruBuilder> WithScopedValues(this ConcurrentLruBuilder builder) where V : IDisposable + /// A ScopedConcurrentLruBuilder. + public static ScopedConcurrentLruBuilder> AsScopedCache(this ConcurrentLruBuilder builder) where V : IDisposable { - var scoped = new ConcurrentLruBuilder>(builder.info); - return new ScopedLruBuilder>(scoped); + var convertBuilder = new ConcurrentLruBuilder>(builder.info); + return new ScopedConcurrentLruBuilder>(convertBuilder); } - public static AtomicLruBuilder WithAtomicCreate(this ConcurrentLruBuilder b) + /// + /// Build an IScopedCache. IDisposable values are wrapped in a lifetime scope. Scoped caches return lifetimes that prevent + /// values from being disposed until the calling code completes. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The AtomicConcurrentLruBuilder to chain method calls onto. + /// An AtomicScopedConcurrentLruBuilder. + public static AtomicScopedConcurrentLruBuilder AsScopedCache(this AtomicConcurrentLruBuilder builder) where V : IDisposable { - var a = new ConcurrentLruBuilder>(b.info); - return new AtomicLruBuilder(a); + var convertBuilder = new ConcurrentLruBuilder>(builder.info); + return new AtomicScopedConcurrentLruBuilder(convertBuilder); } - public static ScopedAtomicLruBuilder WithAtomicCreate(this ScopedLruBuilder b) where V : IDisposable where W : IScoped + /// + /// Build an IScopedAsyncCache. IDisposable values are wrapped in a lifetime scope. Scoped caches return lifetimes that prevent + /// values from being disposed until the calling code completes. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The AsyncConcurrentLruBuilder to chain method calls onto. + /// A ScopedAsyncConcurrentLruBuilder. + public static ScopedAsyncConcurrentLruBuilder AsScopedCache(this AsyncConcurrentLruBuilder builder) where V : IDisposable { - var atomicScoped = new ConcurrentLruBuilder>(b.info); - - return new ScopedAtomicLruBuilder(atomicScoped); + var convertBuilder = new AsyncConcurrentLruBuilder>(builder.info); + return new ScopedAsyncConcurrentLruBuilder(convertBuilder); } - public static ScopedAtomicLruBuilder WithScopedValues(this AtomicLruBuilder b) where V : IDisposable + /// + /// Build an IScopedAsyncCache. IDisposable values are wrapped in a lifetime scope. Scoped caches return lifetimes that prevent + /// values from being disposed until the calling code completes. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The AtomicAsyncConcurrentLruBuilder to chain method calls onto. + /// An AtomicScopedAsyncConcurrentLruBuilder. + public static AtomicScopedAsyncConcurrentLruBuilder AsScopedCache(this AtomicAsyncConcurrentLruBuilder builder) where V : IDisposable { - var atomicScoped = new ConcurrentLruBuilder>(b.info); - return new ScopedAtomicLruBuilder(atomicScoped); + var convertBuilder = new AsyncConcurrentLruBuilder>(builder.info); + return new AtomicScopedAsyncConcurrentLruBuilder(convertBuilder); } - public static AsyncConcurrentLruBuilder AsAsyncCache(this ConcurrentLruBuilder builder) + /// + /// Execute the cache's GetOrAdd value factory atomically, such that it is applied at most once per key. Other threads + /// attempting to update the same key will be blocked until value factory completes. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The ConcurrentLruBuilder to chain method calls onto. + /// An AtomicConcurrentLruBuilder. + public static AtomicConcurrentLruBuilder WithAtomicValueFactory(this ConcurrentLruBuilder builder) { - return new AsyncConcurrentLruBuilder(builder.info); + var convertBuilder = new ConcurrentLruBuilder>(builder.info); + return new AtomicConcurrentLruBuilder(convertBuilder); } - public static ScopedAsyncLruBuilder WithScopedValues(this AsyncConcurrentLruBuilder b) where V : IDisposable + /// + /// Execute the cache's ScopedGetOrAdd value factory atomically, such that it is applied at most once per key. Other threads + /// attempting to update the same key will be blocked until value factory completes. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The wrapped value type. + /// The ScopedConcurrentLruBuilder to chain method calls onto. + /// An AtomicScopedConcurrentLruBuilder. + public static AtomicScopedConcurrentLruBuilder WithAtomicValueFactory(this ScopedConcurrentLruBuilder builder) where V : IDisposable where W : IScoped { - var asyncScoped = new AsyncConcurrentLruBuilder>(b.info); - return new ScopedAsyncLruBuilder(asyncScoped); + var convertBuilder = new ConcurrentLruBuilder>(builder.info); + return new AtomicScopedConcurrentLruBuilder(convertBuilder); } - public static ScopedAsyncLruBuilder AsAsyncCache(this ScopedLruBuilder> b) where V : IDisposable + /// + /// Execute the cache's GetOrAddAsync value factory atomically, such that it is applied at most once per key. Other threads + /// attempting to update the same key will wait on the same value factory task. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The AsyncConcurrentLruBuilder to chain method calls onto. + /// An AtomicAsyncConcurrentLruBuilder. + public static AtomicAsyncConcurrentLruBuilder WithAtomicValueFactory(this AsyncConcurrentLruBuilder builder) { - var asyncScoped = new AsyncConcurrentLruBuilder>(b.info); - return new ScopedAsyncLruBuilder(asyncScoped); + var convertBuilder = new ConcurrentLruBuilder>(builder.info); + return new AtomicAsyncConcurrentLruBuilder(convertBuilder); } - public static AsyncAtomicLruBuilder AsAsyncCache(this AtomicLruBuilder b) + /// + /// Execute the cache's ScopedGetOrAddAsync value factory atomically, such that it is applied at most once per key. Other threads + /// attempting to update the same key will wait on the same value factory task. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The ScopedAsyncConcurrentLruBuilder to chain method calls onto. + /// An AtomicScopedAsyncConcurrentLruBuilder. + public static AtomicScopedAsyncConcurrentLruBuilder WithAtomicValueFactory(this ScopedAsyncConcurrentLruBuilder builder) where V : IDisposable { - var a = new ConcurrentLruBuilder>(b.info); - return new AsyncAtomicLruBuilder(a); + var convertBuilder = new AsyncConcurrentLruBuilder>(builder.info); + return new AtomicScopedAsyncConcurrentLruBuilder(convertBuilder); } - public static AsyncAtomicLruBuilder WithAtomicCreate(this AsyncConcurrentLruBuilder b) + /// + /// Build an IAsyncCache, the GetOrAdd method becomes GetOrAddAsync. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The ConcurrentLruBuilder to chain method calls onto. + /// An AsyncConcurrentLruBuilder. + public static AsyncConcurrentLruBuilder AsAsyncCache(this ConcurrentLruBuilder builder) { - var a = new ConcurrentLruBuilder>(b.info); - return new AsyncAtomicLruBuilder(a); + return new AsyncConcurrentLruBuilder(builder.info); } - public static ScopedAsyncAtomicLruBuilder AsAsyncCache(this ScopedAtomicLruBuilder b) where V : IDisposable + /// + /// Build an IScopedAsyncCache, the ScopedGetOrAdd method becomes ScopedGetOrAddAsync. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The ScopedConcurrentLruBuilder to chain method calls onto. + /// A ScopedAsyncConcurrentLruBuilder. + public static ScopedAsyncConcurrentLruBuilder AsAsyncCache(this ScopedConcurrentLruBuilder> builder) where V : IDisposable { - var a = new AsyncConcurrentLruBuilder>(b.info); - return new ScopedAsyncAtomicLruBuilder(a); + var convertBuilder = new AsyncConcurrentLruBuilder>(builder.info); + return new ScopedAsyncConcurrentLruBuilder(convertBuilder); } - public static ScopedAsyncAtomicLruBuilder WithScopedValues(this AsyncAtomicLruBuilder b) where V : IDisposable + /// + /// Build an IAsyncCache, the GetOrAdd method becomes GetOrAddAsync. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The AtomicConcurrentLruBuilder to chain method calls onto. + /// An AtomicAsyncConcurrentLruBuilder. + public static AtomicAsyncConcurrentLruBuilder AsAsyncCache(this AtomicConcurrentLruBuilder builder) { - var a = new AsyncConcurrentLruBuilder>(b.info); - return new ScopedAsyncAtomicLruBuilder(a); + var convertBuilder = new ConcurrentLruBuilder>(builder.info); + return new AtomicAsyncConcurrentLruBuilder(convertBuilder); } - public static ScopedAsyncAtomicLruBuilder WithAtomicCreate(this ScopedAsyncLruBuilder b) where V : IDisposable + /// + /// Build an IScopedAsyncCache, the ScopedGetOrAdd method becomes ScopedGetOrAddAsync. + /// + /// The type of keys in the cache. + /// The type of values in the cache. + /// The AtomicScopedConcurrentLruBuilder to chain method calls onto. + /// An AtomicScopedAsyncConcurrentLruBuilder. + public static AtomicScopedAsyncConcurrentLruBuilder AsAsyncCache(this AtomicScopedConcurrentLruBuilder builder) where V : IDisposable { - var a = new AsyncConcurrentLruBuilder>(b.info); - return new ScopedAsyncAtomicLruBuilder(a); + var convertBuilder = new AsyncConcurrentLruBuilder>(builder.info); + return new AtomicScopedAsyncConcurrentLruBuilder(convertBuilder); } } }