An open API service indexing awesome lists of open source software.

https://github.com/bitfaster/bitfaster.caching.dependencyinjection

Extension methods for setting up caches using Microsoft.Extensions.DependencyInjection.
https://github.com/bitfaster/bitfaster.caching.dependencyinjection

Last synced: 8 months ago
JSON representation

Extension methods for setting up caches using Microsoft.Extensions.DependencyInjection.

Awesome Lists containing this project

README

          

# BitFaster.Caching.DependencyInjection
Extension methods for setting up [caches](https://github.com/bitfaster/BitFaster.Caching/wiki/Caches) using [Microsoft.Extensions.DependencyInjection](https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection/).

[![NuGet version](https://badge.fury.io/nu/BitFaster.Caching.DependencyInjection.svg)](https://badge.fury.io/nu/BitFaster.Caching.DependencyInjection)
![Nuget](https://img.shields.io/nuget/dt/BitFaster.Caching.DependencyInjection)
![.NET Core](https://github.com/bitfaster/BitFaster.Caching.DependencyInjection/actions/workflows/gate.yml/badge.svg?main)
[![Coverage Status](https://coveralls.io/repos/github/bitfaster/BitFaster.Caching.DependencyInjection/badge.svg?branch=main)](https://coveralls.io/github/bitfaster/BitFaster.Caching.DependencyInjection?branch=main)

# ConcurrentLru

To use with an `IServiceCollection` instance at startup:

```cs
services.AddLru(builder =>
builder
.WithCapacity(666)
.Build());
```

This adds a `ConcurrentLru` where the key is an integer and the cached value is a string. The builder delegate is used to configure the registered cache with a capacity of 666, see the [wiki](https://github.com/bitfaster/BitFaster.Caching/wiki/ConcurrentLru-Quickstart#builder-api) for more details about the builder API and configurable cache features.

There is an extension method for each [cache interface](https://github.com/bitfaster/BitFaster.Caching/wiki/Caches):

| Extension | Result |
|-----------|--------|
| `AddLru` | Registers `ConcurrentLru` as a singleton `ICache` |
| `AddAsyncLru` | Registers `ConcurrentLru` as a singleton `IAsyncCache` |
| `AddScopedLru` | Registers `ConcurrentLru` as a singleton `IScopedCache` |
| `AddScopedAsyncLru` | Registers `ConcurrentLru` as a singleton `IScopedAsyncCache` |

# ConcurrentLfu

To use with an `IServiceCollection` instance at startup:

```cs
services.AddLfu(builder =>
builder
.WithCapacity(666)
.Build());
```

This adds a `ConcurrentLfu` where the key is an integer and the cached value is a string. The builder delegate is used to configure the registered cache with a capacity of 666, see the [wiki](https://github.com/bitfaster/BitFaster.Caching/wiki/ConcurrentLfu-Quickstart#builder-api) for more details about the builder API and configurable cache features.

There is an extension method for each [cache interface](https://github.com/bitfaster/BitFaster.Caching/wiki/Caches):

| Extension | Result |
|-----------|--------|
| `AddLfu` | Registers `ConcurrentLfu` as a singleton `ICache` |
| `AddAsyncLfu` | Registers `ConcurrentLfu` as a singleton `IAsyncCache` |
| `AddScopedLfu` | Registers `ConcurrentLfu` as a singleton `IScopedCache` |
| `AddScopedAsyncLfu` | Registers `ConcurrentLfu` as a singleton `IScopedAsyncCache` |