Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/Lru/LruAsyncGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, string> concurrentLru = new ConcurrentLruBuilder<int, string>().AsAsyncCache().Build();
private static readonly IAsyncCache<int, string> atomicConcurrentLru = new ConcurrentLruBuilder<int, string>().AsAsyncCache().WithAtomicCreate().Build();
private static readonly IAsyncCache<int, string> atomicConcurrentLru = new ConcurrentLruBuilder<int, string>().AsAsyncCache().WithAtomicValueFactory().Build();

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

Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class LruJustGetOrAdd
private static readonly FastConcurrentLru<int, int> fastConcurrentLru = new FastConcurrentLru<int, int>(8, 9, EqualityComparer<int>.Default);
private static readonly FastConcurrentTLru<int, int> fastConcurrentTLru = new FastConcurrentTLru<int, int>(8, 9, EqualityComparer<int>.Default, TimeSpan.FromMinutes(1));

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

private static readonly int key = 1;
private static System.Runtime.Caching.MemoryCache memoryCache = System.Runtime.Caching.MemoryCache.Default;
Expand Down
56 changes: 22 additions & 34 deletions BitFaster.Caching.UnitTests/Lru/ConcurrentLruBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void TestPartitionCapacity()
public void WithScopedValues()
{
IScopedCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithScopedValues()
.AsScopedCache()
.WithCapacity(3)
.Build();

Expand All @@ -209,7 +209,7 @@ public void WithScopedValues()
public void WithAtomicFactory()
{
ICache<int, int> lru = new ConcurrentLruBuilder<int, int>()
.WithAtomicCreate()
.WithAtomicValueFactory()
.WithCapacity(3)
.Build();

Expand All @@ -233,8 +233,8 @@ public void AsAsync()
public void WithAtomicWithScope()
{
IScopedCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithAtomicCreate()
.WithScopedValues()
.WithAtomicValueFactory()
.AsScopedCache()
.WithCapacity(3)
.Build();

Expand All @@ -247,8 +247,8 @@ public void WithAtomicWithScope()
public void WithScopedWithAtomic()
{
IScopedCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithScopedValues()
.WithAtomicCreate()
.AsScopedCache()
.WithAtomicValueFactory()
.WithCapacity(3)
.Build();

Expand All @@ -262,7 +262,7 @@ public void AsAsyncWithScoped()
{
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.AsAsyncCache()
.WithScopedValues()
.AsScopedCache()
.WithCapacity(3)
.Build();

Expand All @@ -276,7 +276,7 @@ public void AsAsyncWithScoped()
public void WithScopedAsAsync()
{
IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithScopedValues()
.AsScopedCache()
.AsAsyncCache()
.WithCapacity(3)
.Build();
Expand All @@ -290,7 +290,7 @@ public void WithScopedAsAsync()
public void WithAtomicAsAsync()
{
IAsyncCache<int, int> lru = new ConcurrentLruBuilder<int, int>()
.WithAtomicCreate()
.WithAtomicValueFactory()
.AsAsyncCache()
.WithCapacity(3)
.Build();
Expand All @@ -304,7 +304,7 @@ public void AsAsyncWithAtomic()
{
IAsyncCache<int, int> lru = new ConcurrentLruBuilder<int, int>()
.AsAsyncCache()
.WithAtomicCreate()
.WithAtomicValueFactory()
.WithCapacity(3)
.Build();

Expand All @@ -315,11 +315,9 @@ public void AsAsyncWithAtomic()
[Fact]
public void WithAtomicWithScopedAsAsync()
{
// TODO: this will not resolve a TLru

IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithAtomicCreate()
.WithScopedValues()
.WithAtomicValueFactory()
.AsScopedCache()
.AsAsyncCache()
.WithCapacity(3)
.Build();
Expand All @@ -331,12 +329,10 @@ public void WithAtomicWithScopedAsAsync()
[Fact]
public void WithAtomicAsAsyncWithScoped()
{
// TODO: this will not resolve a TLru

IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithAtomicCreate()
.WithAtomicValueFactory()
.AsAsyncCache()
.WithScopedValues()
.AsScopedCache()
.WithCapacity(3)
.Build();

Expand All @@ -347,11 +343,9 @@ public void WithAtomicAsAsyncWithScoped()
[Fact]
public void WithScopedWithAtomicAsAsync()
{
// TODO: this will not resolve a TLru

IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithScopedValues()
.WithAtomicCreate()
.AsScopedCache()
.WithAtomicValueFactory()
.AsAsyncCache()
.WithCapacity(3)
.Build();
Expand All @@ -363,12 +357,10 @@ public void WithScopedWithAtomicAsAsync()
[Fact]
public void WithScopedAsAsyncWithAtomic()
{
// TODO: this will not resolve a TLru

IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.WithScopedValues()
.AsScopedCache()
.AsAsyncCache()
.WithAtomicCreate()
.WithAtomicValueFactory()
.WithCapacity(3)
.Build();

Expand All @@ -379,12 +371,10 @@ public void WithScopedAsAsyncWithAtomic()
[Fact]
public void AsAsyncWithScopedWithAtomic()
{
// TODO: this will not resolve a TLru

IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.AsAsyncCache()
.WithScopedValues()
.WithAtomicCreate()
.AsScopedCache()
.WithAtomicValueFactory()
.WithCapacity(3)
.Build();

Expand All @@ -395,12 +385,10 @@ public void AsAsyncWithScopedWithAtomic()
[Fact]
public void AsAsyncWithAtomicWithScoped()
{
// TODO: this will not resolve a TLru

IScopedAsyncCache<int, Disposable> lru = new ConcurrentLruBuilder<int, Disposable>()
.AsAsyncCache()
.WithAtomicCreate()
.WithScopedValues()
.WithAtomicValueFactory()
.AsScopedCache()
.WithCapacity(3)
.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace BitFaster.Caching.Lru.Builder
{
public class AsyncAtomicLruBuilder<K, V> : LruBuilderBase<K, V, AsyncAtomicLruBuilder<K, V>, IAsyncCache<K, V>>
public class AtomicAsyncConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicAsyncConcurrentLruBuilder<K, V>, IAsyncCache<K, V>>
{
private readonly ConcurrentLruBuilder<K, AsyncAtomicFactory<K, V>> inner;

internal AsyncAtomicLruBuilder(ConcurrentLruBuilder<K, AsyncAtomicFactory<K, V>> inner)
internal AtomicAsyncConcurrentLruBuilder(ConcurrentLruBuilder<K, AsyncAtomicFactory<K, V>> inner)
: base(inner.info)
{
this.inner = inner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace BitFaster.Caching.Lru.Builder
{
public class AtomicLruBuilder<K, V> : LruBuilderBase<K, V, AtomicLruBuilder<K, V>, ICache<K, V>>
public class AtomicConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicConcurrentLruBuilder<K, V>, ICache<K, V>>
{
private readonly ConcurrentLruBuilder<K, AtomicFactory<K, V>> inner;

internal AtomicLruBuilder(ConcurrentLruBuilder<K, AtomicFactory<K, V>> inner)
internal AtomicConcurrentLruBuilder(ConcurrentLruBuilder<K, AtomicFactory<K, V>> inner)
: base(inner.info)
{
this.inner = inner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace BitFaster.Caching.Lru.Builder
{
public sealed class ScopedAsyncAtomicLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAsyncAtomicLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
public sealed class AtomicScopedAsyncConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicScopedAsyncConcurrentLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
{
private readonly AsyncConcurrentLruBuilder<K, ScopedAsyncAtomicFactory<K, V>> inner;

internal ScopedAsyncAtomicLruBuilder(AsyncConcurrentLruBuilder<K, ScopedAsyncAtomicFactory<K, V>> inner)
internal AtomicScopedAsyncConcurrentLruBuilder(AsyncConcurrentLruBuilder<K, ScopedAsyncAtomicFactory<K, V>> inner)
: base(inner.info)
{
this.inner = inner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace BitFaster.Caching.Lru.Builder
{
public class ScopedAtomicLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAtomicLruBuilder<K, V>, IScopedCache<K, V>> where V : IDisposable
public class AtomicScopedConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, AtomicScopedConcurrentLruBuilder<K, V>, IScopedCache<K, V>> where V : IDisposable
{
private readonly ConcurrentLruBuilder<K, ScopedAtomicFactory<K, V>> inner;

internal ScopedAtomicLruBuilder(ConcurrentLruBuilder<K, ScopedAtomicFactory<K, V>> inner)
internal AtomicScopedConcurrentLruBuilder(ConcurrentLruBuilder<K, ScopedAtomicFactory<K, V>> inner)
: base(inner.info)
{
this.inner = inner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

namespace BitFaster.Caching.Lru.Builder
{
public sealed class ScopedAsyncLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAsyncLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
public sealed class ScopedAsyncConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, ScopedAsyncConcurrentLruBuilder<K, V>, IScopedAsyncCache<K, V>> where V : IDisposable
{
private readonly AsyncConcurrentLruBuilder<K, Scoped<V>> inner;

internal ScopedAsyncLruBuilder(AsyncConcurrentLruBuilder<K, Scoped<V>> inner)
internal ScopedAsyncConcurrentLruBuilder(AsyncConcurrentLruBuilder<K, Scoped<V>> inner)
: base(inner.info)
{
this.inner = inner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace BitFaster.Caching.Lru.Builder
{
public sealed class ScopedLruBuilder<K, V, W> : LruBuilderBase<K, V, ScopedLruBuilder<K, V, W>, IScopedCache<K, V>> where V : IDisposable where W : IScoped<V>
public sealed class ScopedConcurrentLruBuilder<K, V, W> : LruBuilderBase<K, V, ScopedConcurrentLruBuilder<K, V, W>, IScopedCache<K, V>> where V : IDisposable where W : IScoped<V>
{
private readonly ConcurrentLruBuilder<K, W> inner;

internal ScopedLruBuilder(ConcurrentLruBuilder<K, W> inner)
internal ScopedConcurrentLruBuilder(ConcurrentLruBuilder<K, W> inner)
: base(inner.info)
{
this.inner = inner;
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/ConcurrentLruBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace BitFaster.Caching.Lru
public sealed class ConcurrentLruBuilder<K, V> : LruBuilderBase<K, V, ConcurrentLruBuilder<K, V>, ICache<K, V>>
{
/// <summary>
/// Creates a ConcurrentLruBuilder.
/// Creates a ConcurrentLruBuilder. Chain method calls onto ConcurrentLruBuilder to configure the cache then call Build to create a cache instance.
/// </summary>
public ConcurrentLruBuilder()
: base(new LruInfo<K>())
Expand Down
Loading