|
1 | 1 | # BitFaster.Caching.DependencyInjection |
2 | | -Extension methods for setting up caches using Microsoft.Extensions.DependencyInjection. |
| 2 | +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/). |
3 | 3 |
|
4 | 4 | # ConcurrentLru |
5 | 5 |
|
| 6 | +To use with an `IServiceCollection` instance at startup: |
| 7 | + |
6 | 8 | ```cs |
7 | 9 | services.AddLru<int, int>(builder => |
8 | 10 | builder |
9 | 11 | .WithCapacity(666) |
10 | 12 | .Build()); |
11 | 13 | ``` |
12 | 14 |
|
| 15 | +The builder delegate is used to configure the registered cache, see the [wiki](https://github.com/bitfaster/BitFaster.Caching/wiki/ConcurrentLru-Quickstart#builder-api) for more details about the builder API. |
| 16 | + |
| 17 | +There is an extension method for each [cache interface](https://github.com/bitfaster/BitFaster.Caching/wiki/Caches): |
| 18 | + |
| 19 | +| Extension | Result | |
| 20 | +|-----------|--------| |
| 21 | +| `AddLru` | Registers `ConcurrentLru<int, int>` as a singleton `ICache<int, int>` | |
| 22 | +| `AddAsyncLru` | Registers `ConcurrentLru<int, int>` as a singleton `IAsyncCache<int, int>` | |
| 23 | +| `AddScopedLru` | Registers `ConcurrentLru<int, Disposable>` as a singleton `IScopedCache<int, Disposable>` | |
| 24 | +| `AddScopedAsyncLru` | Registers `ConcurrentLru<int, Disposable>` as a singleton `IScopedAsyncCache<int, Disposable>` | |
| 25 | + |
13 | 26 |
|
14 | 27 | # ConcurrentLfu |
15 | 28 |
|
| 29 | +To use with an `IServiceCollection` instance at startup: |
| 30 | + |
16 | 31 | ```cs |
17 | 32 | services.AddLfu<int, int>(builder => |
18 | 33 | builder |
19 | 34 | .WithCapacity(666) |
20 | 35 | .Build()); |
21 | 36 | ``` |
| 37 | + |
| 38 | +The builder delegate is used to configure the registered cache, see the [wiki](https://github.com/bitfaster/BitFaster.Caching/wiki/ConcurrentLfu-Quickstart#builder-api) for more details about the builder API. |
| 39 | + |
| 40 | +There is an extension method for each [cache interface](https://github.com/bitfaster/BitFaster.Caching/wiki/Caches): |
| 41 | + |
| 42 | +| Extension | Result | |
| 43 | +|-----------|--------| |
| 44 | +| `AddLfu` | Registers `ConcurrentLfu<int, int>` as a singleton `ICache<int, int>` | |
| 45 | +| `AddAsyncLfu` | Registers `ConcurrentLfu<int, int>` as a singleton `IAsyncCache<int, int>` | |
| 46 | +| `AddScopedLfu` | Registers `ConcurrentLfu<int, Disposable>` as a singleton `IScopedCache<int, Disposable>` | |
| 47 | +| `AddScopedAsyncLfu` | Registers `ConcurrentLfu<int, Disposable>` as a singleton `IScopedAsyncCache<int, Disposable>` | |
0 commit comments