Skip to content

Commit 99720ef

Browse files
authored
Merge pull request #6 from bitfaster/users/alexpeck/pkg
pkg
2 parents eb2eee5 + 3185b99 commit 99720ef

File tree

6 files changed

+120
-2
lines changed

6 files changed

+120
-2
lines changed

.github/workflows/gate.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ jobs:
2323
run: dotnet build src --configuration Release --no-restore
2424
- name: Test
2525
run: dotnet test src --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
26+
- name: Publish NuGet artifacts
27+
uses: actions/upload-artifact@v3
28+
with:
29+
name: NuGet package
30+
path: src/BitFaster.Caching.DependencyInjection/bin/Release/
2631
- name: Publish coverage report to coveralls.io
2732
uses: coverallsapp/github-action@master
2833
with:

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
11
# 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/).
33

44
# ConcurrentLru
55

6+
To use with an `IServiceCollection` instance at startup:
7+
68
```cs
79
services.AddLru<int, int>(builder =>
810
builder
911
.WithCapacity(666)
1012
.Build());
1113
```
1214

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+
1326

1427
# ConcurrentLfu
1528

29+
To use with an `IServiceCollection` instance at startup:
30+
1631
```cs
1732
services.AddLfu<int, int>(builder =>
1833
builder
1934
.WithCapacity(666)
2035
.Build());
2136
```
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>` |

src/BitFaster.Caching.DependencyInjection/BitFaster.Caching.DependencyInjection.csproj

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,45 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<Copyright>Copyright © Alex Peck $([System.DateTime]::Now.ToString(yyyy))</Copyright>
6+
<RepositoryUrl>https://github.com/bitfaster/BitFaster.Caching.DependencyInjection</RepositoryUrl>
7+
<PackageProjectUrl></PackageProjectUrl>
8+
<Authors>Alex Peck</Authors>
9+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10+
<Company />
11+
<Product>BitFaster.Caching</Product>
12+
<Description>BitFaster.Caching extensions for Microsoft.Extensions.DependencyInjection.</Description>
13+
<PackageTags>DependencyInjection</PackageTags>
14+
<PackageId>BitFaster.Caching.DependencyInjection</PackageId>
15+
<AssemblyName>BitFaster.Caching.DependencyInjection</AssemblyName>
16+
<RootNamespace>BitFaster.Caching.DependencyInjection</RootNamespace>
17+
<Version>1.0.0</Version>
18+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
19+
<FileVersion>1.0.0.0</FileVersion>
20+
<IncludeSource>True</IncludeSource>
21+
<IncludeSymbols>True</IncludeSymbols>
22+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
23+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
24+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
525
</PropertyGroup>
626

27+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
28+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
29+
</PropertyGroup>
30+
31+
<ItemGroup>
32+
<None Include="..\..\LICENSE">
33+
<Pack>True</Pack>
34+
<PackagePath></PackagePath>
35+
</None>
36+
<None Include="README.md" Pack="true" PackagePath="\" />
37+
</ItemGroup>
38+
739
<ItemGroup>
840
<PackageReference Include="BitFaster.Caching" Version="2.1.0" />
941
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.0" />
1042
</ItemGroup>
11-
43+
<ItemGroup>
44+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
45+
</ItemGroup>
1246
</Project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
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/).
2+
3+
# ConcurrentLru
4+
5+
To use with an `IServiceCollection` instance at startup:
6+
7+
```cs
8+
services.AddLru<int, int>(builder =>
9+
builder
10+
.WithCapacity(666)
11+
.Build());
12+
```
13+
14+
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.
15+
16+
There is an extension method for each [cache interface](https://github.com/bitfaster/BitFaster.Caching/wiki/Caches):
17+
18+
| Extension | Result |
19+
|-----------|--------|
20+
| `AddLru` | Registers `ConcurrentLru<int, int>` as a singleton `ICache<int, int>` |
21+
| `AddAsyncLru` | Registers `ConcurrentLru<int, int>` as a singleton `IAsyncCache<int, int>` |
22+
| `AddScopedLru` | Registers `ConcurrentLru<int, Disposable>` as a singleton `IScopedCache<int, Disposable>` |
23+
| `AddScopedAsyncLru` | Registers `ConcurrentLru<int, Disposable>` as a singleton `IScopedAsyncCache<int, Disposable>` |
24+
25+
26+
# ConcurrentLfu
27+
28+
To use with an `IServiceCollection` instance at startup:
29+
30+
```cs
31+
services.AddLfu<int, int>(builder =>
32+
builder
33+
.WithCapacity(666)
34+
.Build());
35+
```
36+
37+
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.
38+
39+
There is an extension method for each [cache interface](https://github.com/bitfaster/BitFaster.Caching/wiki/Caches):
40+
41+
| Extension | Result |
42+
|-----------|--------|
43+
| `AddLfu` | Registers `ConcurrentLfu<int, int>` as a singleton `ICache<int, int>` |
44+
| `AddAsyncLfu` | Registers `ConcurrentLfu<int, int>` as a singleton `IAsyncCache<int, int>` |
45+
| `AddScopedLfu` | Registers `ConcurrentLfu<int, Disposable>` as a singleton `IScopedCache<int, Disposable>` |
46+
| `AddScopedAsyncLfu` | Registers `ConcurrentLfu<int, Disposable>` as a singleton `IScopedAsyncCache<int, Disposable>` |

src/BitFaster.snk

596 Bytes
Binary file not shown.

src/Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
<PropertyGroup>
4+
<AssemblyOriginatorKeyFile Condition="EXISTS('..\BitFaster.snk')">..\BitFaster.snk</AssemblyOriginatorKeyFile>
5+
<SignAssembly>true</SignAssembly>
6+
</PropertyGroup>
7+
</Project>

0 commit comments

Comments
 (0)