Skip to content

Conversation

@bitfaster
Copy link
Owner

@bitfaster bitfaster commented Jul 20, 2022

Fluent builder for creating all cache types. Uses recursive generic and extension methods to support changing the returned cache type:

Example:

ICache<int, int> scopedlru = new ConcurrentLruBuilder<int, int>()
    .WithConcurrencyLevel(12)
    .WithCapacity(3)
    .WithMetrics()
    .WithExpireAfterWrite(TimeSpan.FromMinutes(1))
    .Build();

IScopedCache<int, Disposable> scopedlru = new ConcurrentLruBuilder<int, Disposable>()
    .WithScopedValues()
    .WithConcurrencyLevel(12)
    .WithCapacity(3)
    .WithMetrics()
    .WithExpireAfterWrite(TimeSpan.FromMinutes(1))
    .Build();

PR #125 shows how to extend to more cache types using generics.

@bitfaster bitfaster changed the title Users/alexpeck/builder2 builder Jul 20, 2022
@bitfaster bitfaster marked this pull request as ready for review July 20, 2022 04:13
@bitfaster bitfaster merged commit 2ccc6dc into main Jul 20, 2022
@bitfaster bitfaster deleted the users/alexpeck/builder2 branch July 20, 2022 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants