Skip to content

Commit 6fc5c51

Browse files
authored
cleanup builders (#165)
* rename * comments * rename
1 parent dc49552 commit 6fc5c51

11 files changed

+159
-87
lines changed

BitFaster.Caching.Benchmarks/Lru/LruAsyncGet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class LruAsyncGet
2020
{
2121
// if the cache value is a value type, value task has no effect - so use string to repro.
2222
private static readonly IAsyncCache<int, string> concurrentLru = new ConcurrentLruBuilder<int, string>().AsAsyncCache().Build();
23-
private static readonly IAsyncCache<int, string> atomicConcurrentLru = new ConcurrentLruBuilder<int, string>().AsAsyncCache().WithAtomicCreate().Build();
23+
private static readonly IAsyncCache<int, string> atomicConcurrentLru = new ConcurrentLruBuilder<int, string>().AsAsyncCache().WithAtomicValueFactory().Build();
2424

2525
private static Task<string> returnTask = Task.FromResult("1");
2626

BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class LruJustGetOrAdd
4444
private static readonly FastConcurrentLru<int, int> fastConcurrentLru = new FastConcurrentLru<int, int>(8, 9, EqualityComparer<int>.Default);
4545
private static readonly FastConcurrentTLru<int, int> fastConcurrentTLru = new FastConcurrentTLru<int, int>(8, 9, EqualityComparer<int>.Default, TimeSpan.FromMinutes(1));
4646

47-
private static readonly ICache<int, int> atomicFastLru = new ConcurrentLruBuilder<int, int>().WithConcurrencyLevel(8).WithCapacity(9).WithAtomicCreate().Build();
47+
private static readonly ICache<int, int> atomicFastLru = new ConcurrentLruBuilder<int, int>().WithConcurrencyLevel(8).WithCapacity(9).WithAtomicValueFactory().Build();
4848

4949
private static readonly int key = 1;
5050
private static System.Runtime.Caching.MemoryCache memoryCache = System.Runtime.Caching.MemoryCache.Default;

BitFaster.Caching.UnitTests/Lru/ConcurrentLruBuilderTests.cs

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void TestPartitionCapacity()
196196
public void WithScopedValues()
197197
{
198198
IScopedCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
199-
.WithScopedValues()
199+
.AsScopedCache()
200200
.WithCapacity(3)
201201
.Build();
202202

@@ -209,7 +209,7 @@ public void WithScopedValues()
209209
public void WithAtomicFactory()
210210
{
211211
ICache<int, int> lru = new ConcurrentLruBuilder<int, int>()
212-
.WithAtomicCreate()
212+
.WithAtomicValueFactory()
213213
.WithCapacity(3)
214214
.Build();
215215

@@ -233,8 +233,8 @@ public void AsAsync()
233233
public void WithAtomicWithScope()
234234
{
235235
IScopedCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
236-
.WithAtomicCreate()
237-
.WithScopedValues()
236+
.WithAtomicValueFactory()
237+
.AsScopedCache()
238238
.WithCapacity(3)
239239
.Build();
240240

@@ -247,8 +247,8 @@ public void WithAtomicWithScope()
247247
public void WithScopedWithAtomic()
248248
{
249249
IScopedCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
250-
.WithScopedValues()
251-
.WithAtomicCreate()
250+
.AsScopedCache()
251+
.WithAtomicValueFactory()
252252
.WithCapacity(3)
253253
.Build();
254254

@@ -262,7 +262,7 @@ public void AsAsyncWithScoped()
262262
{
263263
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
264264
.AsAsyncCache()
265-
.WithScopedValues()
265+
.AsScopedCache()
266266
.WithCapacity(3)
267267
.Build();
268268

@@ -276,7 +276,7 @@ public void AsAsyncWithScoped()
276276
public void WithScopedAsAsync()
277277
{
278278
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
279-
.WithScopedValues()
279+
.AsScopedCache()
280280
.AsAsyncCache()
281281
.WithCapacity(3)
282282
.Build();
@@ -290,7 +290,7 @@ public void WithScopedAsAsync()
290290
public void WithAtomicAsAsync()
291291
{
292292
IAsyncCache<int, int> lru = new ConcurrentLruBuilder<int, int>()
293-
.WithAtomicCreate()
293+
.WithAtomicValueFactory()
294294
.AsAsyncCache()
295295
.WithCapacity(3)
296296
.Build();
@@ -304,7 +304,7 @@ public void AsAsyncWithAtomic()
304304
{
305305
IAsyncCache<int, int> lru = new ConcurrentLruBuilder<int, int>()
306306
.AsAsyncCache()
307-
.WithAtomicCreate()
307+
.WithAtomicValueFactory()
308308
.WithCapacity(3)
309309
.Build();
310310

@@ -315,11 +315,9 @@ public void AsAsyncWithAtomic()
315315
[Fact]
316316
public void WithAtomicWithScopedAsAsync()
317317
{
318-
// TODO: this will not resolve a TLru
319-
320318
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
321-
.WithAtomicCreate()
322-
.WithScopedValues()
319+
.WithAtomicValueFactory()
320+
.AsScopedCache()
323321
.AsAsyncCache()
324322
.WithCapacity(3)
325323
.Build();
@@ -331,12 +329,10 @@ public void WithAtomicWithScopedAsAsync()
331329
[Fact]
332330
public void WithAtomicAsAsyncWithScoped()
333331
{
334-
// TODO: this will not resolve a TLru
335-
336332
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
337-
.WithAtomicCreate()
333+
.WithAtomicValueFactory()
338334
.AsAsyncCache()
339-
.WithScopedValues()
335+
.AsScopedCache()
340336
.WithCapacity(3)
341337
.Build();
342338

@@ -347,11 +343,9 @@ public void WithAtomicAsAsyncWithScoped()
347343
[Fact]
348344
public void WithScopedWithAtomicAsAsync()
349345
{
350-
// TODO: this will not resolve a TLru
351-
352346
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
353-
.WithScopedValues()
354-
.WithAtomicCreate()
347+
.AsScopedCache()
348+
.WithAtomicValueFactory()
355349
.AsAsyncCache()
356350
.WithCapacity(3)
357351
.Build();
@@ -363,12 +357,10 @@ public void WithScopedWithAtomicAsAsync()
363357
[Fact]
364358
public void WithScopedAsAsyncWithAtomic()
365359
{
366-
// TODO: this will not resolve a TLru
367-
368360
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
369-
.WithScopedValues()
361+
.AsScopedCache()
370362
.AsAsyncCache()
371-
.WithAtomicCreate()
363+
.WithAtomicValueFactory()
372364
.WithCapacity(3)
373365
.Build();
374366

@@ -379,12 +371,10 @@ public void WithScopedAsAsyncWithAtomic()
379371
[Fact]
380372
public void AsAsyncWithScopedWithAtomic()
381373
{
382-
// TODO: this will not resolve a TLru
383-
384374
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
385375
.AsAsyncCache()
386-
.WithScopedValues()
387-
.WithAtomicCreate()
376+
.AsScopedCache()
377+
.WithAtomicValueFactory()
388378
.WithCapacity(3)
389379
.Build();
390380

@@ -395,12 +385,10 @@ public void AsAsyncWithScopedWithAtomic()
395385
[Fact]
396386
public void AsAsyncWithAtomicWithScoped()
397387
{
398-
// TODO: this will not resolve a TLru
399-
400388
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
401389
.AsAsyncCache()
402-
.WithAtomicCreate()
403-
.WithScopedValues()
390+
.WithAtomicValueFactory()
391+
.AsScopedCache()
404392
.WithCapacity(3)
405393
.Build();
406394

BitFaster.Caching/Lru/Builder/AsyncAtomicLruBuilder.cs renamed to BitFaster.Caching/Lru/Builder/AtomicAsyncConcurrentLruBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace BitFaster.Caching.Lru.Builder
99
{
10-
public class AsyncAtomicLruBuilder<K, V> : LruBuilderBase<K, V, AsyncAtomicLruBuilder<K, V>, IAsyncCache<K, V>>
10+
public class AtomicAsyncConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicAsyncConcurrentLruBuilder<K, V>, IAsyncCache<K, V>>
1111
{
1212
private readonly ConcurrentLruBuilder<K, AsyncAtomicFactory<K, V>> inner;
1313

14-
internal AsyncAtomicLruBuilder(ConcurrentLruBuilder<K, AsyncAtomicFactory<K, V>> inner)
14+
internal AtomicAsyncConcurrentLruBuilder(ConcurrentLruBuilder<K, AsyncAtomicFactory<K, V>> inner)
1515
: base(inner.info)
1616
{
1717
this.inner = inner;

BitFaster.Caching/Lru/Builder/AtomicLruBuilder.cs renamed to BitFaster.Caching/Lru/Builder/AtomicConcurrentLruBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace BitFaster.Caching.Lru.Builder
99
{
10-
public class AtomicLruBuilder<K, V> : LruBuilderBase<K, V, AtomicLruBuilder<K, V>, ICache<K, V>>
10+
public class AtomicConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicConcurrentLruBuilder<K, V>, ICache<K, V>>
1111
{
1212
private readonly ConcurrentLruBuilder<K, AtomicFactory<K, V>> inner;
1313

14-
internal AtomicLruBuilder(ConcurrentLruBuilder<K, AtomicFactory<K, V>> inner)
14+
internal AtomicConcurrentLruBuilder(ConcurrentLruBuilder<K, AtomicFactory<K, V>> inner)
1515
: base(inner.info)
1616
{
1717
this.inner = inner;

BitFaster.Caching/Lru/Builder/ScopedAsyncAtomicLruBuilder.cs renamed to BitFaster.Caching/Lru/Builder/AtomicScopedAsyncConcurrentLruBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace BitFaster.Caching.Lru.Builder
99
{
10-
public sealed class ScopedAsyncAtomicLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAsyncAtomicLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
10+
public sealed class AtomicScopedAsyncConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicScopedAsyncConcurrentLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
1111
{
1212
private readonly AsyncConcurrentLruBuilder<K, ScopedAsyncAtomicFactory<K, V>> inner;
1313

14-
internal ScopedAsyncAtomicLruBuilder(AsyncConcurrentLruBuilder<K, ScopedAsyncAtomicFactory<K, V>> inner)
14+
internal AtomicScopedAsyncConcurrentLruBuilder(AsyncConcurrentLruBuilder<K, ScopedAsyncAtomicFactory<K, V>> inner)
1515
: base(inner.info)
1616
{
1717
this.inner = inner;

BitFaster.Caching/Lru/Builder/ScopedAtomicLruBuilder.cs renamed to BitFaster.Caching/Lru/Builder/AtomicScopedConcurrentLruBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace BitFaster.Caching.Lru.Builder
99
{
10-
public class ScopedAtomicLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAtomicLruBuilder<K, V>, IScopedCache<K, V>> where V : IDisposable
10+
public class AtomicScopedConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicScopedConcurrentLruBuilder<K, V>, IScopedCache<K, V>> where V : IDisposable
1111
{
1212
private readonly ConcurrentLruBuilder<K, ScopedAtomicFactory<K, V>> inner;
1313

14-
internal ScopedAtomicLruBuilder(ConcurrentLruBuilder<K, ScopedAtomicFactory<K, V>> inner)
14+
internal AtomicScopedConcurrentLruBuilder(ConcurrentLruBuilder<K, ScopedAtomicFactory<K, V>> inner)
1515
: base(inner.info)
1616
{
1717
this.inner = inner;

BitFaster.Caching/Lru/Builder/ScopedAsyncLruBuilder.cs renamed to BitFaster.Caching/Lru/Builder/ScopedAsyncConcurrentLruBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
namespace BitFaster.Caching.Lru.Builder
88
{
9-
public sealed class ScopedAsyncLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAsyncLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
9+
public sealed class ScopedAsyncConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAsyncConcurrentLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
1010
{
1111
private readonly AsyncConcurrentLruBuilder<K, Scoped<V>> inner;
1212

13-
internal ScopedAsyncLruBuilder(AsyncConcurrentLruBuilder<K, Scoped<V>> inner)
13+
internal ScopedAsyncConcurrentLruBuilder(AsyncConcurrentLruBuilder<K, Scoped<V>> inner)
1414
: base(inner.info)
1515
{
1616
this.inner = inner;

BitFaster.Caching/Lru/Builder/ScopedLruBuilder.cs renamed to BitFaster.Caching/Lru/Builder/ScopedConcurrentLruBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace BitFaster.Caching.Lru.Builder
99
{
10-
public sealed class ScopedLruBuilder<K, V, W> : LruBuilderBase<K, V, ScopedLruBuilder<K, V, W>, IScopedCache<K, V>> where V : IDisposable where W : IScoped<V>
10+
public sealed class ScopedConcurrentLruBuilder<K, V, W> : LruBuilderBase<K, V, ScopedConcurrentLruBuilder<K, V, W>, IScopedCache<K, V>> where V : IDisposable where W : IScoped<V>
1111
{
1212
private readonly ConcurrentLruBuilder<K, W> inner;
1313

14-
internal ScopedLruBuilder(ConcurrentLruBuilder<K, W> inner)
14+
internal ScopedConcurrentLruBuilder(ConcurrentLruBuilder<K, W> inner)
1515
: base(inner.info)
1616
{
1717
this.inner = inner;

BitFaster.Caching/Lru/ConcurrentLruBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace BitFaster.Caching.Lru
2424
public sealed class ConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, ConcurrentLruBuilder<K, V>, ICache<K, V>>
2525
{
2626
/// <summary>
27-
/// Creates a ConcurrentLruBuilder.
27+
/// Creates a ConcurrentLruBuilder. Chain method calls onto ConcurrentLruBuilder to configure the cache then call Build to create a cache instance.
2828
/// </summary>
2929
public ConcurrentLruBuilder()
3030
: base(new LruInfo<K>())

0 commit comments

Comments
 (0)