diff --git a/.editorconfig b/.editorconfig
index e58aad46..1e70922a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -130,6 +130,25 @@ csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# Xml project files
+
+# CA1305: Specify IFormatProvider
+dotnet_diagnostic.CA1305.severity = suggestion
+
+# CA1303: Do not pass literals as localized parameters
+dotnet_diagnostic.CA1303.severity = suggestion
+
+# CS8602: Dereference of a possibly null reference.
+dotnet_diagnostic.CS8602.severity = error
+
+# CA1716: Identifiers should not match keywords
+dotnet_diagnostic.CA1716.severity = silent
+
+# CA1825: Avoid zero-length array allocations.
+dotnet_diagnostic.CA1825.severity = silent
+
+# CA1028: Enum Storage should be Int32
+dotnet_diagnostic.CA1028.severity = silent
+
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2
@@ -143,4 +162,4 @@ indent_size = 2
# Shell scripts
[*.sh]
-end_of_line = lf
\ No newline at end of file
+end_of_line = lf
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 00000000..76e3c49b
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+github: MichaCo
diff --git a/Benchmarks.md b/Benchmarks.md
index c626dca1..a7321c58 100644
--- a/Benchmarks.md
+++ b/Benchmarks.md
@@ -1,6 +1,8 @@
## Benchmarks
+TODO: needs update
+
Benchmarks have been implemented with [BenchmarkDotNet](https://github.com/PerfDotNet/BenchmarkDotNet).
All CacheManager instances used in the benchmarks have only one cache handle configured, either the Dictionary, System.Runtime or Redis handle.
diff --git a/CacheManager.sln b/CacheManager.sln
index 8681186a..292ee09e 100644
--- a/CacheManager.sln
+++ b/CacheManager.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26430.13
+# Visual Studio Version 17
+VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{58CC885F-40A7-4C82-990D-3F36AAA088A7}"
EndProject
@@ -10,7 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
Benchmarks.md = Benchmarks.md
tools\CodeAnalysis.ruleset = tools\CodeAnalysis.ruleset
- docfx.json = docfx.json
README.md = README.md
tools\stylecop.json = tools\stylecop.json
EndProjectSection
@@ -41,12 +40,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.SystemRuntimeC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.StackExchange.Redis", "src\CacheManager.StackExchange.Redis\CacheManager.StackExchange.Redis.csproj", "{BA03975E-39CD-4318-8ED3-239AA399DC87}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Couchbase", "src\CacheManager.Couchbase\CacheManager.Couchbase.csproj", "{6436C729-A28B-4D90-B3B8-7ED003341199}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Web", "src\CacheManager.Web\CacheManager.Web.csproj", "{4FBE8026-2FAE-462C-9446-33B49CA5A25D}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Config.Tests", "test\CacheManager.Config.Tests\CacheManager.Config.Tests.csproj", "{35A16A79-63DE-418E-AF5E-6865E5718008}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Tests", "test\CacheManager.Tests\CacheManager.Tests.csproj", "{EEED5086-976C-4063-A61D-D5FAE7652758}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Examples", "samples\CacheManager.Examples\CacheManager.Examples.csproj", "{8F8E0F73-F11A-4F9A-91F5-9C8E798752D9}"
@@ -55,25 +48,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Serialization.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Microsoft.Extensions.Configuration", "src\CacheManager.Microsoft.Extensions.Configuration\CacheManager.Microsoft.Extensions.Configuration.csproj", "{D68182DA-FB4D-45A9-9A09-AD07A45FE5FF}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Microsoft.Extensions.Logging", "src\CacheManager.Microsoft.Extensions.Logging\CacheManager.Microsoft.Extensions.Logging.csproj", "{97C864BD-D4C7-4DF6-92D0-4D76A89F6706}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Memcached", "src\CacheManager.Memcached\CacheManager.Memcached.csproj", "{5E5AFEF6-C13E-4D78-87D6-50407002A9B1}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.MSConfiguration.TypeLoad.Tests", "test\CacheManager.MSConfiguration.TypeLoad.Tests\CacheManager.MSConfiguration.TypeLoad.Tests.csproj", "{360D0B25-F9EB-4553-92DC-FB0FD24EF344}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Microsoft.Extensions.Caching.Memory", "src\CacheManager.Microsoft.Extensions.Caching.Memory\CacheManager.Microsoft.Extensions.Caching.Memory.csproj", "{48DD6E04-0CFD-4FB4-A178-749B0FBFBA36}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Serialization.ProtoBuf", "src\CacheManager.Serialization.ProtoBuf\CacheManager.Serialization.ProtoBuf.csproj", "{85CD8BC7-3E72-422E-AF91-6FDF2133E155}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspnetCore.WebApp", "samples\AspnetCore.WebApp\AspnetCore.WebApp.csproj", "{CB9C05BF-E567-412F-B3C8-C85289E60DBC}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Serialization.Bond", "src\CacheManager.Serialization.Bond\CacheManager.Serialization.Bond.csproj", "{2FB30F61-B2E7-43AC-80AF-C45218F1D4BA}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Benchmarks", "test\CacheManager.Benchmarks\CacheManager.Benchmarks.csproj", "{987C4CD7-D162-4635-8C50-214A25494676}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{CB286D98-C974-4266-B8F2-1F9DE8B2B0EC}"
ProjectSection(SolutionItems) = preProject
- appveyor.yml = appveyor.yml
+ azure-pipelines-ci.yml = azure-pipelines-ci.yml
tools\common.props = tools\common.props
NuGet.Config = NuGet.Config
tools\version.props = tools\version.props
@@ -86,9 +71,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "schema", "schema", "{DB13A4
tools\RedisCfg.xsd = tools\RedisCfg.xsd
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CacheManager.Events.Tests", "test\CacheManager.Events.Tests\CacheManager.Events.Tests.csproj", "{AA4A2053-1ECD-4331-B805-BF8062B04CFC}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Serialization.DataContract", "src\CacheManager.Serialization.DataContract\CacheManager.Serialization.DataContract.csproj", "{38709D89-E43C-44E3-A865-39BBEBF28D98}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{81E202D2-BEB7-4BAF-B7BE-53D628120F8A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Benchmarks", "benchmarks\CacheManager.Benchmarks\CacheManager.Benchmarks.csproj", "{8B8E87C2-5FD1-4D17-901A-53713566A84D}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Examples.Configuration", "samples\CacheManager.Examples.Configuration\CacheManager.Examples.Configuration.csproj", "{29E6BC78-BD1E-4E83-AAC6-D3D21DA883AB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Config.Tests", "benchmarks\CacheManager.Config.Tests\CacheManager.Config.Tests.csproj", "{C7745B11-4A2E-4278-9F1E-774AC7153CD2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheManager.Events.Tests", "benchmarks\CacheManager.Events.Tests\CacheManager.Events.Tests.csproj", "{2DF724CF-E4F3-4663-880C-5359F2EAEA1A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "samples\AspNetCore\Web.csproj", "{1291DAA1-25C8-4648-9216-BF338EE5C2DD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -108,18 +101,6 @@ Global
{BA03975E-39CD-4318-8ED3-239AA399DC87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA03975E-39CD-4318-8ED3-239AA399DC87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA03975E-39CD-4318-8ED3-239AA399DC87}.Release|Any CPU.Build.0 = Release|Any CPU
- {6436C729-A28B-4D90-B3B8-7ED003341199}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6436C729-A28B-4D90-B3B8-7ED003341199}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6436C729-A28B-4D90-B3B8-7ED003341199}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6436C729-A28B-4D90-B3B8-7ED003341199}.Release|Any CPU.Build.0 = Release|Any CPU
- {4FBE8026-2FAE-462C-9446-33B49CA5A25D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4FBE8026-2FAE-462C-9446-33B49CA5A25D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4FBE8026-2FAE-462C-9446-33B49CA5A25D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4FBE8026-2FAE-462C-9446-33B49CA5A25D}.Release|Any CPU.Build.0 = Release|Any CPU
- {35A16A79-63DE-418E-AF5E-6865E5718008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {35A16A79-63DE-418E-AF5E-6865E5718008}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {35A16A79-63DE-418E-AF5E-6865E5718008}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {35A16A79-63DE-418E-AF5E-6865E5718008}.Release|Any CPU.Build.0 = Release|Any CPU
{EEED5086-976C-4063-A61D-D5FAE7652758}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEED5086-976C-4063-A61D-D5FAE7652758}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEED5086-976C-4063-A61D-D5FAE7652758}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -136,14 +117,6 @@ Global
{D68182DA-FB4D-45A9-9A09-AD07A45FE5FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D68182DA-FB4D-45A9-9A09-AD07A45FE5FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D68182DA-FB4D-45A9-9A09-AD07A45FE5FF}.Release|Any CPU.Build.0 = Release|Any CPU
- {97C864BD-D4C7-4DF6-92D0-4D76A89F6706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {97C864BD-D4C7-4DF6-92D0-4D76A89F6706}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {97C864BD-D4C7-4DF6-92D0-4D76A89F6706}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {97C864BD-D4C7-4DF6-92D0-4D76A89F6706}.Release|Any CPU.Build.0 = Release|Any CPU
- {5E5AFEF6-C13E-4D78-87D6-50407002A9B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5E5AFEF6-C13E-4D78-87D6-50407002A9B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5E5AFEF6-C13E-4D78-87D6-50407002A9B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5E5AFEF6-C13E-4D78-87D6-50407002A9B1}.Release|Any CPU.Build.0 = Release|Any CPU
{360D0B25-F9EB-4553-92DC-FB0FD24EF344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{360D0B25-F9EB-4553-92DC-FB0FD24EF344}.Debug|Any CPU.Build.0 = Debug|Any CPU
{360D0B25-F9EB-4553-92DC-FB0FD24EF344}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -156,26 +129,30 @@ Global
{85CD8BC7-3E72-422E-AF91-6FDF2133E155}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85CD8BC7-3E72-422E-AF91-6FDF2133E155}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85CD8BC7-3E72-422E-AF91-6FDF2133E155}.Release|Any CPU.Build.0 = Release|Any CPU
- {CB9C05BF-E567-412F-B3C8-C85289E60DBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CB9C05BF-E567-412F-B3C8-C85289E60DBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CB9C05BF-E567-412F-B3C8-C85289E60DBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CB9C05BF-E567-412F-B3C8-C85289E60DBC}.Release|Any CPU.Build.0 = Release|Any CPU
{2FB30F61-B2E7-43AC-80AF-C45218F1D4BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FB30F61-B2E7-43AC-80AF-C45218F1D4BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FB30F61-B2E7-43AC-80AF-C45218F1D4BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FB30F61-B2E7-43AC-80AF-C45218F1D4BA}.Release|Any CPU.Build.0 = Release|Any CPU
- {987C4CD7-D162-4635-8C50-214A25494676}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {987C4CD7-D162-4635-8C50-214A25494676}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {987C4CD7-D162-4635-8C50-214A25494676}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {987C4CD7-D162-4635-8C50-214A25494676}.Release|Any CPU.Build.0 = Release|Any CPU
- {AA4A2053-1ECD-4331-B805-BF8062B04CFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {AA4A2053-1ECD-4331-B805-BF8062B04CFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {AA4A2053-1ECD-4331-B805-BF8062B04CFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {AA4A2053-1ECD-4331-B805-BF8062B04CFC}.Release|Any CPU.Build.0 = Release|Any CPU
- {29E6BC78-BD1E-4E83-AAC6-D3D21DA883AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {29E6BC78-BD1E-4E83-AAC6-D3D21DA883AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {29E6BC78-BD1E-4E83-AAC6-D3D21DA883AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {29E6BC78-BD1E-4E83-AAC6-D3D21DA883AB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {38709D89-E43C-44E3-A865-39BBEBF28D98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {38709D89-E43C-44E3-A865-39BBEBF28D98}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {38709D89-E43C-44E3-A865-39BBEBF28D98}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {38709D89-E43C-44E3-A865-39BBEBF28D98}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8B8E87C2-5FD1-4D17-901A-53713566A84D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8B8E87C2-5FD1-4D17-901A-53713566A84D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8B8E87C2-5FD1-4D17-901A-53713566A84D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8B8E87C2-5FD1-4D17-901A-53713566A84D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C7745B11-4A2E-4278-9F1E-774AC7153CD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C7745B11-4A2E-4278-9F1E-774AC7153CD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C7745B11-4A2E-4278-9F1E-774AC7153CD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C7745B11-4A2E-4278-9F1E-774AC7153CD2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2DF724CF-E4F3-4663-880C-5359F2EAEA1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2DF724CF-E4F3-4663-880C-5359F2EAEA1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2DF724CF-E4F3-4663-880C-5359F2EAEA1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2DF724CF-E4F3-4663-880C-5359F2EAEA1A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1291DAA1-25C8-4648-9216-BF338EE5C2DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1291DAA1-25C8-4648-9216-BF338EE5C2DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1291DAA1-25C8-4648-9216-BF338EE5C2DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1291DAA1-25C8-4648-9216-BF338EE5C2DD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -185,25 +162,24 @@ Global
{C9B4E53B-15FC-42AF-9107-0C2E52E8680B} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
{49A1A508-1A92-4F6A-8654-B0E71C07BD53} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
{BA03975E-39CD-4318-8ED3-239AA399DC87} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
- {6436C729-A28B-4D90-B3B8-7ED003341199} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
- {4FBE8026-2FAE-462C-9446-33B49CA5A25D} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
- {35A16A79-63DE-418E-AF5E-6865E5718008} = {C013E552-43F5-4496-BE29-DB401C3334BB}
{EEED5086-976C-4063-A61D-D5FAE7652758} = {C013E552-43F5-4496-BE29-DB401C3334BB}
{8F8E0F73-F11A-4F9A-91F5-9C8E798752D9} = {C23C189C-3AFC-45D6-8E32-9B5E190BBA20}
{3F3A3386-DFED-489C-A97D-541D43AA6C12} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
{D68182DA-FB4D-45A9-9A09-AD07A45FE5FF} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
- {97C864BD-D4C7-4DF6-92D0-4D76A89F6706} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
- {5E5AFEF6-C13E-4D78-87D6-50407002A9B1} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
{360D0B25-F9EB-4553-92DC-FB0FD24EF344} = {C013E552-43F5-4496-BE29-DB401C3334BB}
{48DD6E04-0CFD-4FB4-A178-749B0FBFBA36} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
{85CD8BC7-3E72-422E-AF91-6FDF2133E155} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
- {CB9C05BF-E567-412F-B3C8-C85289E60DBC} = {C23C189C-3AFC-45D6-8E32-9B5E190BBA20}
{2FB30F61-B2E7-43AC-80AF-C45218F1D4BA} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
- {987C4CD7-D162-4635-8C50-214A25494676} = {C013E552-43F5-4496-BE29-DB401C3334BB}
{CB286D98-C974-4266-B8F2-1F9DE8B2B0EC} = {D83D3737-3BD4-4AEE-8C42-CDED9410DB79}
{DB13A410-EAF1-4966-BA56-FC73BAC7CF3D} = {D83D3737-3BD4-4AEE-8C42-CDED9410DB79}
- {AA4A2053-1ECD-4331-B805-BF8062B04CFC} = {C013E552-43F5-4496-BE29-DB401C3334BB}
- {29E6BC78-BD1E-4E83-AAC6-D3D21DA883AB} = {C23C189C-3AFC-45D6-8E32-9B5E190BBA20}
+ {38709D89-E43C-44E3-A865-39BBEBF28D98} = {58CC885F-40A7-4C82-990D-3F36AAA088A7}
+ {8B8E87C2-5FD1-4D17-901A-53713566A84D} = {81E202D2-BEB7-4BAF-B7BE-53D628120F8A}
+ {C7745B11-4A2E-4278-9F1E-774AC7153CD2} = {81E202D2-BEB7-4BAF-B7BE-53D628120F8A}
+ {2DF724CF-E4F3-4663-880C-5359F2EAEA1A} = {81E202D2-BEB7-4BAF-B7BE-53D628120F8A}
+ {1291DAA1-25C8-4648-9216-BF338EE5C2DD} = {C23C189C-3AFC-45D6-8E32-9B5E190BBA20}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {55AD6484-7AB9-4CE1-B604-3410DA3876C0}
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
diff --git a/LICENSE b/LICENSE
index e06d2081..261eeb9e 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Apache License
+ Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
@@ -178,7 +178,7 @@ Apache License
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
+ boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
@@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright {yyyy} {name of copyright owner}
+ Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -199,4 +199,3 @@ Apache License
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
diff --git a/NuGet.Config b/NuGet.Config
index 37fbe07c..39983a7e 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -1,8 +1,6 @@
-
-
\ No newline at end of file
+
diff --git a/README.md b/README.md
index c7d45467..87cd6fce 100644
--- a/README.md
+++ b/README.md
@@ -8,29 +8,41 @@ The developer can opt-in to those features only if needed.
## Build Status
-Build Server | Status
+Branch | Status
--- | :---:
-Windows, MSBuild | [](https://ci.appveyor.com/project/MichaCo/cachemanager-ak9g3)
-Linux, Mono | -
+Dev | [](https://dev.azure.com/michaco/CacheManager/_build/latest?definitionId=3&branchName=dev)
+Master | [](https://dev.azure.com/michaco/CacheManager/_build/latest?definitionId=3&branchName=master)
## CacheManager Nuget Packages
-| Package Name | .Net 4.0 | .Net 4.5 | .NET Standard
-|--------------| :-------: | :-------: | :-------:
-| [CacheManager.Core][Core.nuget] | x | x | 1.2
-| [CacheManager.StackExchange.Redis][Redis.nuget] | - | x | 1.5
-| [CacheManager.SystemRuntimeCaching][SystemRuntimeCaching.nuget] | x | x | -
-| [CacheManager.Microsoft.Extensions.Caching.Memory][MSCache.nuget] | - | x | 1.3
-| [CacheManager.Microsoft.Extensions.Configuration][Configuration.nuget] | - | x | 1.2
-| [CacheManager.Microsoft.Extensions.Logging][Logging.nuget] | - | x | 1.2
-| [CacheManager.Serialization.Bond][Bond.nuget] | x | x | 1.2
-| [CacheManager.Serialization.Json][Json.nuget] | x | x | 1.2
-| [CacheManager.Serialization.ProtoBuf][ProtoBuf.nuget] | x | x | 1.3
-| [CacheManager.Web][Web.nuget] | - | x | -
-| [CacheManager.Memcached][Memcached.nuget] | x | x | -
-| [CacheManager.Couchbase][Couchbase.nuget] | - | x | 1.5
-
-### Beta Packages
+| Package Name | FullFramework | .NET Standard | net8.0 |
+| -------------- | :-------: | :-------: | :-------: |
+| [CacheManager.Core][Core.nuget] | 4.7.2 | 2.0 | net8.0 |
+| [CacheManager.Microsoft.Extensions.Caching.Memory][MSCache.nuget] | - | 2.0 | net8.0 |
+| [CacheManager.Microsoft.Extensions.Configuration][Configuration.nuget] | - | 2.0 | net8.0 |
+| [CacheManager.Serialization.Bond][Bond.nuget] | - | 2.0 | net8.0 |
+| [CacheManager.Serialization.DataContract][DataContract.nuget] | - | 2.0 | net8.0 |
+| [CacheManager.Serialization.Json][Json.nuget] | - | 2.0 | net8.0 |
+| [CacheManager.Serialization.ProtoBuf][ProtoBuf.nuget] | - | 2.0 | net8.0 |
+| [CacheManager.StackExchange.Redis][Redis.nuget] | 4.7.2 | 2.0 | net8.0 |
+| [CacheManager.SystemRuntimeCaching][SystemRuntimeCaching.nuget] | 4.7.2 | 2.0 | net8.0 |
+
+## Version 2.0 Breaking Changes
+
+* CacheManager.Microsoft.Extensions.Logging is not a separated package anymore. Logging is now part of the Core package.
+* CacheManager.Memcached is not supported anymore
+* CacheManager.Couchbase is not supported anymore
+* CacheManager.Web is not supported anymore
+* PerformanceCounters are not available for now
+
+### Testing with Microsoft.Garnet
+
+For testing and benchmarking, this project is now using Microsoft.Garnet, which allows to create a Redis server which runs in process and is easy to setup.
+This has some limitations though and before you use Microsoft.Garnet in production, be aware that for example key space notifications are not supported yet.
+
+See https://github.com/microsoft/garnet for details.
+
+## Beta Packages
Beta versions of the CacheManager packages are getting pushed to https://www.myget.org/gallery/cachemanager on each build.
Add the following feed, if you want to play with the not yet released bits:
@@ -77,9 +89,6 @@ See [benchmarks results](https://github.com/MichaCo/CacheManager/blob/dev/Benchm
* **MemoryCache** (System.Runtime.Caching)
* **MemoryCache** based on Microsoft.Extensions.Caching.Memory
* **Redis** using [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis)
- * **Memcached** using [Enyim.Memcached](https://github.com/enyim/EnyimMemcached)
- * **Couchbase** using [Couchbase.Net.Client v2](https://github.com/couchbase/couchbase-net-client)
- * **System.Web.Caching** based (included in the Web package)
* **Serialization** can now be configured.
Serialization is only needed in distributed caches. If no additional serialization package is installed and configured, Binary serialization will be used (if available)
The following are the currently available serialization options:
@@ -87,14 +96,12 @@ The following are the currently available serialization options:
* **Json** based on the popular Newtonsoft.Json library
* **Json** with Gzip compression
* **Bond** based on Microsoft.Bond supporting all three available variants
+ * **DataContract** based on System.Runtime.Serialization library supporting binary, Json & Json with Gzip compression
* **Protocol Buffer** Google's protobuf. The package uses Mark's [protobuf-net](https://github.com/mgravell/protobuf-net) implementation.
* **Update values with lock or transaction** for distributed caches.
The interfaced provides a simple update method which internally ensures you work with the latest version.
And CacheManager handles version conflicts for you.
-* **Logging** CacheManager comes with an extensible logging API.
- * All standard cache operations are logged
- * Based on log levels more or less information will be logged (try Trace and Debug)
- * Current concrete implementation is based on the ASP.NET Core logging. Other implementation of CacheManager's ILoggerFactory might follow.
+* **Logging** using Microsoft.Extensions.Logging.
* **Strongly typed** cache interface.
* **Multiple layers**
By having multiple cache handles managed by CacheManager, you can easily implement layered caches. For example, an in process cache in front of your distributed cache, to make read access faster.
@@ -112,16 +119,13 @@ The following are the supported expiration modes:
* **Cache Regions**: Even if some cache systems do not support or implement cache regions, the CacheManager implements the mechanism.
This can be used to for example group elements and remove all of them at once.
* **Statistics**: Counters for all kind of cache actions.
-* **Performance Counters**: To be able to inspect certain numbers with `perfmon`, CacheManager supports performance counters per instance of the manager and per cache handle.
* **Event System**: CacheManager triggers events for common cache actions:
OnGet, OnAdd, OnPut, OnRemove, OnClear, OnClearRegion
* Events also get triggered by the backplane (if enabled) when multiple instances are sharing the same cache.
* New `OnRemoveByHandle` events triggered by actual expiration or memory pressure eviction by the cache vendor
* Events also get triggered through the backplane and via Redis keyspace events (if configured)
-* **System.Web.OutputCache** implementation to use CacheManager as OutputCache provider which makes the OutputCache extremely flexible, for example by using a distributed cache like Redis across many web servers.
* **Cache clients synchronization**
* Implemented with the Redis pub/sub feature
-* Supports .Net 4.0, .Net 4.5, and can be used in cross platform projects with the new **.NET Core** runtime
[releases]: https://github.com/MichaCo/CacheManager/releases
[Core.nuget]: https://www.nuget.org/packages/CacheManager.Core
@@ -152,3 +156,4 @@ OnGet, OnAdd, OnPut, OnRemove, OnClear, OnClearRegion
[MSCache.nuget]: https://www.nuget.org/packages/CacheManager.Microsoft.Extensions.Caching.Memory
[ProtoBuf.nuget]: https://www.nuget.org/packages/CacheManager.Serialization.ProtoBuf
[Bond.nuget]: https://www.nuget.org/packages/CacheManager.Serialization.Bond
+[DataContract.nuget]: https://www.nuget.org
diff --git a/_disable_.travis.yml b/_disable_.travis.yml
deleted file mode 100644
index 96ab1d45..00000000
--- a/_disable_.travis.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-language: csharp
-sudo: required
-dist: trusty
-os:
- - linux
- - osx
-addons:
- apt:
- packages:
- - gettext
- - libcurl4-openssl-dev
- - libicu-dev
- - libssl-dev
- - libunwind8
- - zlib1g
-mono:
- - 4.0.5
-osx_image: xcode7.1
-services:
- - redis-server
-before_install:
- - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install icu4c; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi
-env:
- - KOREBUILD_TEST_SKIPMONO=1
-script:
- - chmod a+x ./build.sh
- - ./build.sh --quiet verify
-
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 2a6e757e..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-version: 1.1.0-beta-{build}
-image: Visual Studio 2017
-configuration: Release
-clone_folder: C:\projects\CacheManager\
-init:
-- cmd: if "%APPVEYOR_REPO_BRANCH%" == "master" (set VersionSuffix=) else (set VersionSuffix=beta)
-environment:
- BuildNumber: $(APPVEYOR_BUILD_NUMBER)
-install:
-- ps: C:\projects\CacheManager\tools\redis\install-service.cmd
-before_build:
-- cmd: dotnet restore
-build:
- project: CacheManager.sln
- parallel: true
- verbosity: minimal
-after_build:
-- cmd: "dotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Core \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Couchbase \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Memcached \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Microsoft.Extensions.Caching.Memory \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Microsoft.Extensions.Configuration \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Microsoft.Extensions.Logging \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Serialization.Json \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Serialization.ProtoBuf \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.StackExchange.Redis \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.SystemRuntimeCaching \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Web \ndotnet pack -o C:\\projects\\CacheManager\\artifacts -c Release src\\CacheManager.Serialization.Bond"
-test_script:
-- cmd: >-
- dotnet test test\CacheManager.Tests\CacheManager.Tests.csproj -c Release --no-build --filter "category!=Unreliable&category!=memcached&category!=Redis"
-
- dotnet test test\CacheManager.MSConfiguration.TypeLoad.Tests\CacheManager.MSConfiguration.TypeLoad.Tests.csproj --no-build -c Release
-artifacts:
-- path: artifacts\*.nupkg
- name: nugets
-deploy:
-- provider: NuGet
- server: https://www.myget.org/F/cachemanager/api/v2/package
- symbol_server: https://www.myget.org/F/cachemanager/api/v2/package
- artifact: nugets
\ No newline at end of file
diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml
new file mode 100644
index 00000000..e973f0d6
--- /dev/null
+++ b/azure-pipelines-ci.yml
@@ -0,0 +1,68 @@
+name: '$(Date:yyyyMMdd)$(Rev:.r)'
+
+trigger:
+- dev
+- master
+
+pr:
+ autoCancel: false
+ branches:
+ include:
+ - '*'
+
+# pool:
+# vmImage: 'windows-latest'
+
+variables:
+ buildPlatform: 'Any CPU'
+ buildConfiguration: 'Release'
+ ${{ if not(eq(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
+ versionSuffix: 'beta-$(Build.BuildNumber)'
+ ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
+ versionSuffix: ''
+
+jobs:
+- job: Windows
+ displayName: 'Build & Test'
+ pool:
+ vmImage: 'windows-latest'
+
+ steps:
+ - task: DotNetCoreCLI@2
+ displayName: 'dotnet build'
+ inputs:
+ command: 'build'
+ projects: |
+ CacheManager.sln
+ arguments: '-c Release'
+ name: 'Build'
+ - task: DotNetCoreCLI@2
+ displayName: "dotnet test"
+ inputs:
+ command: 'test'
+ projects: 'test/**/*.csproj'
+ publishTestResults: true
+ arguments: '-c Release --no-build --no-restore --filter category!=Unreliable'
+ - script: 'dotnet pack src\CacheManager.Core\CacheManager.Core.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack Core'
+ - script: 'dotnet pack src\CacheManager.Microsoft.Extensions.Caching.Memory\CacheManager.Microsoft.Extensions.Caching.Memory.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.Microsoft.Extensions.Caching.Memory'
+ - script: 'dotnet pack src\CacheManager.Microsoft.Extensions.Configuration\CacheManager.Microsoft.Extensions.Configuration.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.Microsoft.Extensions.Configuration'
+ - script: 'dotnet pack src\CacheManager.Serialization.Bond\CacheManager.Serialization.Bond.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.Serialization.Bond'
+ - script: 'dotnet pack src\CacheManager.Serialization.DataContract\CacheManager.Serialization.DataContract.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.Serialization.DataContract'
+ - script: 'dotnet pack src\CacheManager.Serialization.Json\CacheManager.Serialization.Json.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.Serialization.Json'
+ - script: 'dotnet pack src\CacheManager.Serialization.ProtoBuf\CacheManager.Serialization.ProtoBuf.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.Serialization.ProtoBuf'
+ - script: 'dotnet pack src\CacheManager.StackExchange.Redis\CacheManager.StackExchange.Redis.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.StackExchange.Redis'
+ - script: 'dotnet pack src\CacheManager.SystemRuntimeCaching\CacheManager.SystemRuntimeCaching.csproj -c Release --no-build --no-restore --version-suffix "$(versionSuffix)" -v normal -o $(Build.ArtifactStagingDirectory)'
+ displayName: 'dotnet pack CacheManager.SystemRuntimeCaching'
+ - task: PublishBuildArtifacts@1
+ displayName: 'Publish Artifacts'
+ inputs:
+ pathtoPublish: '$(Build.ArtifactStagingDirectory)'
+ artifactName: 'cachemanager'
diff --git a/benchmarks/CacheManager.Benchmarks/.gitignore b/benchmarks/CacheManager.Benchmarks/.gitignore
new file mode 100644
index 00000000..91a99327
--- /dev/null
+++ b/benchmarks/CacheManager.Benchmarks/.gitignore
@@ -0,0 +1 @@
+BenchmarkDotNet.Artifacts/
diff --git a/test/CacheManager.Benchmarks/BackplaneMessageBenchmark.cs b/benchmarks/CacheManager.Benchmarks/BackplaneMessageBenchmark.cs
similarity index 97%
rename from test/CacheManager.Benchmarks/BackplaneMessageBenchmark.cs
rename to benchmarks/CacheManager.Benchmarks/BackplaneMessageBenchmark.cs
index 9ddefcc5..f6694873 100644
--- a/test/CacheManager.Benchmarks/BackplaneMessageBenchmark.cs
+++ b/benchmarks/CacheManager.Benchmarks/BackplaneMessageBenchmark.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using BenchmarkDotNet.Attributes;
@@ -7,6 +8,7 @@
namespace CacheManager.Benchmarks
{
+ [ExcludeFromCodeCoverage]
public class BackplaneMessageBenchmarkMultiple
{
private static byte[] _ownderBytes = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString());
@@ -49,6 +51,7 @@ public void DeserializeMany()
}
}
+ [ExcludeFromCodeCoverage]
public class BackplaneMessageBenchmark
{
private static byte[] _ownderBytes = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString());
@@ -128,4 +131,4 @@ public void DeserializeRemove()
var msg = BackplaneMessage.Deserialize(_rawSingleRemove).ToArray();
}
}
-}
\ No newline at end of file
+}
diff --git a/test/CacheManager.Benchmarks/BaseCacheManagerBenchmark.cs b/benchmarks/CacheManager.Benchmarks/BaseCacheManagerBenchmark.cs
similarity index 81%
rename from test/CacheManager.Benchmarks/BaseCacheManagerBenchmark.cs
rename to benchmarks/CacheManager.Benchmarks/BaseCacheManagerBenchmark.cs
index b165682c..11d655db 100644
--- a/test/CacheManager.Benchmarks/BaseCacheManagerBenchmark.cs
+++ b/benchmarks/CacheManager.Benchmarks/BaseCacheManagerBenchmark.cs
@@ -1,38 +1,28 @@
using System;
-using System.Linq;
+using System.Diagnostics.CodeAnalysis;
using BenchmarkDotNet.Attributes;
using CacheManager.Core;
-using Enyim.Caching;
-using Enyim.Caching.Configuration;
namespace CacheManager.Benchmarks
{
+ [ExcludeFromCodeCoverage]
public abstract class BaseCacheBenchmark
{
private static ICacheManagerConfiguration BaseConfig
- => new ConfigurationBuilder()
- .WithMaxRetries(10)
- .WithRetryTimeout(500)
- .WithJsonSerializer()
- .WithUpdateMode(CacheUpdateMode.Up)
- .Build();
-
- private static IMemcachedClientConfiguration MemcachedConfig
- {
- get
- {
- var cfg = new MemcachedClientConfiguration();
- cfg.AddServer("localhost", 11211);
- return cfg;
- }
- }
+ => new CacheConfigurationBuilder()
+ .WithMaxRetries(10)
+ .WithRetryTimeout(500)
+ .WithJsonSerializer()
+ .WithUpdateMode(CacheUpdateMode.Up)
+ .Build();
+
protected ICacheManager DictionaryCache = new BaseCacheManager(BaseConfig.Builder.WithDictionaryHandle().Build());
protected ICacheManager RuntimeCache = new BaseCacheManager(BaseConfig.Builder.WithSystemRuntimeCacheHandle().Build());
protected ICacheManager RedisCache = new BaseCacheManager(
- BaseConfig
+ BaseConfig
.Builder
.WithRedisConfiguration("redisKey", "localhost:6379,allowAdmin=true")
.WithRedisCacheHandle("redisKey")
@@ -40,18 +30,13 @@ private static IMemcachedClientConfiguration MemcachedConfig
protected ICacheManager MsMemoryCache = new BaseCacheManager(BaseConfig.Builder.WithMicrosoftMemoryCacheHandle().Build());
- protected ICacheManager MemcachedCache =
- new BaseCacheManager(BaseConfig.Builder
- .WithMemcachedCacheHandle(new MemcachedClient(MemcachedConfig)).Build());
-
- [Setup]
+ [GlobalSetup]
public void Setup()
{
DictionaryCache.Clear();
RuntimeCache.Clear();
RedisCache.Clear();
MsMemoryCache.Clear();
- MemcachedCache.Clear();
SetupBench();
}
@@ -79,12 +64,6 @@ public void Redis()
Excecute(RedisCache);
}
- [Benchmark]
- public void Memcached()
- {
- Excecute(MemcachedCache);
- }
-
protected abstract void Excecute(ICacheManager cache);
protected virtual void SetupBench()
@@ -94,6 +73,7 @@ protected virtual void SetupBench()
#region add
+ [ExcludeFromCodeCoverage]
public class AddSingleBenchmark : BaseCacheBenchmark
{
private string _key = Guid.NewGuid().ToString();
@@ -107,6 +87,7 @@ protected override void Excecute(ICacheManager cache)
}
}
+ [ExcludeFromCodeCoverage]
public class AddWithRegionSingleBenchmark : BaseCacheBenchmark
{
private string _key = Guid.NewGuid().ToString();
@@ -124,6 +105,7 @@ protected override void Excecute(ICacheManager cache)
#region put
+ [ExcludeFromCodeCoverage]
public class PutSingleBenchmark : BaseCacheBenchmark
{
private string _key = Guid.NewGuid().ToString();
@@ -134,6 +116,7 @@ protected override void Excecute(ICacheManager cache)
}
}
+ [ExcludeFromCodeCoverage]
public class PutWithRegionSingleBenchmark : BaseCacheBenchmark
{
private string _key = Guid.NewGuid().ToString();
@@ -148,6 +131,7 @@ protected override void Excecute(ICacheManager cache)
#region get
+ [ExcludeFromCodeCoverage]
public class GetSingleBenchmark : BaseCacheBenchmark
{
protected string Key = Guid.NewGuid().ToString();
@@ -171,13 +155,12 @@ protected override void SetupBench()
RuntimeCache.Add(Key, Key, "region");
MsMemoryCache.Add(Key, Key);
MsMemoryCache.Add(Key, Key, "region");
- MemcachedCache.Add(Key, Key);
- MemcachedCache.Add(Key, Key, "region");
RedisCache.Add(Key, Key);
RedisCache.Add(Key, Key, "region");
}
}
+ [ExcludeFromCodeCoverage]
public class GetWithRegionSingleBenchmark : GetSingleBenchmark
{
protected override void Excecute(ICacheManager cache)
@@ -194,6 +177,7 @@ protected override void Excecute(ICacheManager cache)
#region update
+ [ExcludeFromCodeCoverage]
public class UpdateSingleBenchmark : GetSingleBenchmark
{
protected override void Excecute(ICacheManager cache)
@@ -207,4 +191,4 @@ protected override void Excecute(ICacheManager cache)
}
#endregion upate
-}
\ No newline at end of file
+}
diff --git a/test/CacheManager.Benchmarks/CacheManager.Benchmarks.csproj b/benchmarks/CacheManager.Benchmarks/CacheManager.Benchmarks.csproj
similarity index 76%
rename from test/CacheManager.Benchmarks/CacheManager.Benchmarks.csproj
rename to benchmarks/CacheManager.Benchmarks/CacheManager.Benchmarks.csproj
index f34ceb8f..dfcff79b 100644
--- a/test/CacheManager.Benchmarks/CacheManager.Benchmarks.csproj
+++ b/benchmarks/CacheManager.Benchmarks/CacheManager.Benchmarks.csproj
@@ -1,15 +1,15 @@
- net46
+ net8.0
CacheManager.Benchmarks
Exe
CacheManager.Benchmarks
false
false
false
+ false
-
@@ -18,13 +18,9 @@
-
-
-
+
true
-
-
\ No newline at end of file
diff --git a/test/CacheManager.Benchmarks/GzBenchmark.cs b/benchmarks/CacheManager.Benchmarks/GzBenchmark.cs
similarity index 98%
rename from test/CacheManager.Benchmarks/GzBenchmark.cs
rename to benchmarks/CacheManager.Benchmarks/GzBenchmark.cs
index ad50d49a..4b605910 100644
--- a/test/CacheManager.Benchmarks/GzBenchmark.cs
+++ b/benchmarks/CacheManager.Benchmarks/GzBenchmark.cs
@@ -1,6 +1,7 @@
using System;
using System.Buffers;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Linq;
@@ -9,13 +10,14 @@
namespace CacheManager.Benchmarks
{
+ [ExcludeFromCodeCoverage]
public class GzBenchmark
{
private static ArrayPool _pool = ArrayPool.Create();
private byte[] _payload;
- [Setup]
+ [GlobalSetup]
public void Setup()
{
var list = new List();
@@ -170,4 +172,4 @@ public byte[] Decompression(byte[] compressedData)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/test/CacheManager.Benchmarks/PlainDictionaryUpdateBenchmark.cs b/benchmarks/CacheManager.Benchmarks/PlainDictionaryUpdateBenchmark.cs
similarity index 97%
rename from test/CacheManager.Benchmarks/PlainDictionaryUpdateBenchmark.cs
rename to benchmarks/CacheManager.Benchmarks/PlainDictionaryUpdateBenchmark.cs
index 8b7fd44f..fc8fd657 100644
--- a/test/CacheManager.Benchmarks/PlainDictionaryUpdateBenchmark.cs
+++ b/benchmarks/CacheManager.Benchmarks/PlainDictionaryUpdateBenchmark.cs
@@ -1,11 +1,13 @@
using System;
using System.Collections.Concurrent;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
namespace CacheManager.Benchmarks
{
+ [ExcludeFromCodeCoverage]
public class PlainDictionaryUpdateBenchmark
{
private const int Threads = 6;
@@ -92,4 +94,4 @@ private void RunParallel(Action act, int threads, int iterations)
Parallel.Invoke(tasks.ToArray());
}
}
-}
\ No newline at end of file
+}
diff --git a/benchmarks/CacheManager.Benchmarks/Program.cs b/benchmarks/CacheManager.Benchmarks/Program.cs
new file mode 100644
index 00000000..4076da50
--- /dev/null
+++ b/benchmarks/CacheManager.Benchmarks/Program.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
+using BenchmarkDotNet.Configs;
+using BenchmarkDotNet.Jobs;
+using BenchmarkDotNet.Running;
+
+namespace CacheManager.Benchmarks
+{
+ [ExcludeFromCodeCoverage]
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ do
+ {
+ var config = ManualConfig.CreateMinimumViable()
+ .AddJob(Job.Default
+ .WithIterationCount(10)
+ .WithWarmupCount(2)
+ .WithLaunchCount(1))
+ .AddDiagnoser(BenchmarkDotNet.Diagnosers.MemoryDiagnoser.Default);
+
+ BenchmarkSwitcher
+ .FromAssembly(typeof(Program).GetTypeInfo().Assembly)
+ .Run(args, config);
+
+ Console.WriteLine("done!");
+ Console.WriteLine("Press escape to exit or any key to continue...");
+ } while (Console.ReadKey().Key != ConsoleKey.Escape);
+ }
+ }
+}
diff --git a/test/CacheManager.Benchmarks/Properties/AssemblyInfo.cs b/benchmarks/CacheManager.Benchmarks/Properties/AssemblyInfo.cs
similarity index 100%
rename from test/CacheManager.Benchmarks/Properties/AssemblyInfo.cs
rename to benchmarks/CacheManager.Benchmarks/Properties/AssemblyInfo.cs
diff --git a/test/CacheManager.Benchmarks/SerializationBenchmark.cs b/benchmarks/CacheManager.Benchmarks/SerializationBenchmark.cs
similarity index 87%
rename from test/CacheManager.Benchmarks/SerializationBenchmark.cs
rename to benchmarks/CacheManager.Benchmarks/SerializationBenchmark.cs
index 34ffe55a..389b8b61 100644
--- a/test/CacheManager.Benchmarks/SerializationBenchmark.cs
+++ b/benchmarks/CacheManager.Benchmarks/SerializationBenchmark.cs
@@ -1,28 +1,21 @@
using System;
-using System.Buffers;
using System.Collections.Generic;
-using System.IO;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
-using System.Text;
using BenchmarkDotNet.Attributes;
-using BenchmarkDotNet.Configs;
-using BenchmarkDotNet.Environments;
-using BenchmarkDotNet.Jobs;
using CacheManager.Core;
using CacheManager.Core.Internal;
using CacheManager.Serialization.Bond;
using CacheManager.Serialization.Json;
using CacheManager.Serialization.ProtoBuf;
-using Microsoft.Extensions.ObjectPool;
-using Newtonsoft.Json;
namespace CacheManager.Benchmarks
{
+ [ExcludeFromCodeCoverage]
public class SerializationBenchmark
{
private int _iterations = 1000;
private Queue> _payload;
- private BinaryCacheSerializer _binary = new BinaryCacheSerializer();
private JsonCacheSerializer _json = new JsonCacheSerializer();
private GzJsonCacheSerializer _jsonGz = new GzJsonCacheSerializer();
private ProtoBufSerializer _proto = new Serialization.ProtoBuf.ProtoBufSerializer();
@@ -31,7 +24,7 @@ public class SerializationBenchmark
private BondSimpleJsonCacheSerializer _bondSimpleJson = new BondSimpleJsonCacheSerializer();
private readonly Type _pocoType = typeof(TestPoco);
- [Setup]
+ [GlobalSetup]
public void Setup()
{
var rnd = new Random();
@@ -73,20 +66,6 @@ private void ExecRun(Action> action)
_payload.Enqueue(item);
}
- [Benchmark()]
- public void BinarySerializer()
- {
- ExecRun((item) =>
- {
- var data = _binary.SerializeCacheItem(item);
- var result = _binary.DeserializeCacheItem(data, _pocoType);
- if (result == null)
- {
- throw new Exception();
- }
- });
- }
-
[Benchmark(Baseline = true)]
public void JsonSerializer()
{
@@ -171,4 +150,4 @@ public void BondSimpleJsonSerializer()
});
}
}
-}
\ No newline at end of file
+}
diff --git a/test/CacheManager.Benchmarks/TestPoco.cs b/benchmarks/CacheManager.Benchmarks/TestPoco.cs
similarity index 91%
rename from test/CacheManager.Benchmarks/TestPoco.cs
rename to benchmarks/CacheManager.Benchmarks/TestPoco.cs
index a4250f23..b2207156 100644
--- a/test/CacheManager.Benchmarks/TestPoco.cs
+++ b/benchmarks/CacheManager.Benchmarks/TestPoco.cs
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Newtonsoft.Json;
using ProtoBuf;
namespace CacheManager.Benchmarks
{
+ [ExcludeFromCodeCoverage]
[Serializable]
[JsonObject]
[ProtoContract]
@@ -33,6 +35,7 @@ public class TestPoco
public List OList { get; set; }
}
+ [ExcludeFromCodeCoverage]
[Serializable]
[ProtoContract]
[JsonObject]
@@ -49,4 +52,4 @@ public class TestSubPoco
[Bond.Id(2)]
public string Val { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/test/CacheManager.Benchmarks/UnixTimestampBenchmark.cs b/benchmarks/CacheManager.Benchmarks/UnixTimestampBenchmark.cs
similarity index 73%
rename from test/CacheManager.Benchmarks/UnixTimestampBenchmark.cs
rename to benchmarks/CacheManager.Benchmarks/UnixTimestampBenchmark.cs
index 7c52f650..3dffe7c2 100644
--- a/test/CacheManager.Benchmarks/UnixTimestampBenchmark.cs
+++ b/benchmarks/CacheManager.Benchmarks/UnixTimestampBenchmark.cs
@@ -1,10 +1,10 @@
using System;
-using System.Linq;
+using System.Diagnostics.CodeAnalysis;
using BenchmarkDotNet.Attributes;
-using CacheManager.Core.Utility;
namespace CacheManager.Benchmarks
{
+ [ExcludeFromCodeCoverage]
public class UnixTimestampBenchmark
{
[Benchmark(Baseline = true)]
@@ -20,11 +20,5 @@ public long ManualCalcNaive()
{
return (long)(DateTime.UtcNow - _date1970).TotalMilliseconds;
}
-
- [Benchmark()]
- public long ManualCalcOptimized()
- {
- return Clock.GetUnixTimestampMillis();
- }
}
-}
\ No newline at end of file
+}
diff --git a/samples/CacheManager.Examples.Configuration/CacheManager.Examples.Configuration.csproj b/benchmarks/CacheManager.Config.Tests/CacheManager.Config.Tests.csproj
similarity index 54%
rename from samples/CacheManager.Examples.Configuration/CacheManager.Examples.Configuration.csproj
rename to benchmarks/CacheManager.Config.Tests/CacheManager.Config.Tests.csproj
index 56226f1a..3fb140bf 100644
--- a/samples/CacheManager.Examples.Configuration/CacheManager.Examples.Configuration.csproj
+++ b/benchmarks/CacheManager.Config.Tests/CacheManager.Config.Tests.csproj
@@ -1,34 +1,38 @@
+ CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
+ 2.0.0
+ MichaConrad
+ net8.0
+ CacheManager.Config.Tests
Exe
- net462
+ ../../tools/key.snk
+ true
+ true
+ CacheManager.Config.Tests
+ false
-
-
+
+ PreserveNewest
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
- PreserveNewest
-
+
+
-
+
-
\ No newline at end of file
diff --git a/benchmarks/CacheManager.Config.Tests/Program.cs b/benchmarks/CacheManager.Config.Tests/Program.cs
new file mode 100644
index 00000000..41836cd2
--- /dev/null
+++ b/benchmarks/CacheManager.Config.Tests/Program.cs
@@ -0,0 +1,122 @@
+using System;
+using System.Net;
+using System.Threading;
+using System.Threading.Tasks;
+using CacheManager.Core;
+using Garnet;
+using Garnet.client;
+using Garnet.server;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+
+namespace CacheManager.Config.Tests;
+
+internal class Program
+{
+ public static GarnetServer StartServer(ILoggerFactory loggerFactory)
+ {
+ var server = new GarnetServer(new GarnetServerOptions()
+ {
+ EnableLua = true,
+ LuaOptions = new LuaOptions(LuaMemoryManagementMode.Native, string.Empty, TimeSpan.FromSeconds(5)),
+ EndPoint = new IPEndPoint(IPAddress.Loopback, 6379)
+ },
+ loggerFactory: loggerFactory);
+
+ server.Start();
+
+ return server;
+ }
+
+ public static void Main(string[] args)
+ {
+ ThreadPool.SetMinThreads(100, 100);
+
+ var iterations = 100;
+ try
+ {
+ var services = new ServiceCollection();
+
+ services.AddLogging(c =>
+ {
+ c.AddSystemdConsole();
+ c.SetMinimumLevel(LogLevel.Information);
+ });
+
+ var provider = services.BuildServiceProvider();
+ var loggerFactory = provider.GetRequiredService();
+
+ using var server = StartServer(loggerFactory);
+
+ var builder = new Core.CacheConfigurationBuilder("myCache");
+
+ builder
+ .WithRetryTimeout(500)
+ .WithMaxRetries(3);
+
+ builder
+ .WithDictionaryHandle()
+ .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(20))
+ .DisableStatistics();
+
+ builder
+ .WithRedisCacheHandle("redis", true)
+ .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromSeconds(60))
+ .DisableStatistics();
+
+ builder.WithRedisBackplane("redis");
+
+ builder.WithRedisConfiguration("redis", config =>
+ {
+ config
+ //.UseTwemproxy()
+ //.UseCompatibilityMode("2.4")
+ .WithAllowAdmin()
+ .WithDatabase(0)
+ .WithConnectionTimeout(5000)
+ .EnableKeyspaceEvents()
+ .WithEndpoint("127.0.0.1", 6379);
+ });
+
+ //builder.WithRedisConfiguration("redis", "localhost:22121");
+
+ builder.WithBondCompactBinarySerializer();
+
+ var cacheA = new BaseCacheManager(builder.Build());
+ cacheA.Clear();
+
+ for (var i = 0; i < iterations; i++)
+ {
+ try
+ {
+ Tests.PumpData(cacheA).GetAwaiter().GetResult();
+ break; // specified runtime (todo: rework this anyways)
+ }
+ catch (AggregateException ex)
+ {
+ ex.Handle((e) =>
+ {
+ Console.WriteLine(e);
+ return true;
+ });
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace);
+ Thread.Sleep(1000);
+ }
+
+ Console.WriteLine("---------------------------------------------------------");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
+
+ Console.ForegroundColor = ConsoleColor.DarkGreen;
+ Console.WriteLine("We are done...");
+ Console.ForegroundColor = ConsoleColor.Gray;
+ Console.ReadKey();
+ }
+}
diff --git a/test/CacheManager.Config.Tests/Properties/launchSettings.json b/benchmarks/CacheManager.Config.Tests/Properties/launchSettings.json
similarity index 100%
rename from test/CacheManager.Config.Tests/Properties/launchSettings.json
rename to benchmarks/CacheManager.Config.Tests/Properties/launchSettings.json
diff --git a/test/CacheManager.Config.Tests/Settings.StyleCop b/benchmarks/CacheManager.Config.Tests/Settings.StyleCop
similarity index 100%
rename from test/CacheManager.Config.Tests/Settings.StyleCop
rename to benchmarks/CacheManager.Config.Tests/Settings.StyleCop
diff --git a/test/CacheManager.Config.Tests/Tests.cs b/benchmarks/CacheManager.Config.Tests/Tests.cs
similarity index 83%
rename from test/CacheManager.Config.Tests/Tests.cs
rename to benchmarks/CacheManager.Config.Tests/Tests.cs
index 70466053..9cc66e17 100644
--- a/test/CacheManager.Config.Tests/Tests.cs
+++ b/benchmarks/CacheManager.Config.Tests/Tests.cs
@@ -73,6 +73,95 @@ public static void CacheThreadTest(ICacheManager cache, int seed = 42)
eventRemoveCount));
}
+ public static async Task PumpData(ICacheManager cache, int runForSeconds = 300)
+ {
+ var source = new CancellationTokenSource(TimeSpan.FromSeconds(runForSeconds));
+ var maxItems = 500000;
+ var numReaders = 10;
+ var puts = 0;
+ var hits = 0;
+ var misses = 0;
+ var putIterations = 0;
+
+ var pumpTask = Task.Factory.StartNew(
+ () =>
+ {
+ var count = 0;
+ while (!source.Token.IsCancellationRequested)
+ {
+ try
+ {
+ count++;
+ cache.Put("key" + count, Guid.NewGuid().ToString());
+
+ Interlocked.Increment(ref puts);
+
+ if (count == maxItems)
+ {
+ count = 0;
+ cache.Clear();
+ Interlocked.Increment(ref putIterations);
+ }
+ }
+ catch
+ {
+ // resuming if some timeouts happen
+ }
+ }
+ },
+ source.Token);
+
+ var readers = new List();
+ for (var i = 0; i < numReaders; i++)
+ {
+ readers.Add(Read());
+ }
+
+ try
+ {
+ await LogProgress();
+ await Task.WhenAll(readers.ToArray());
+ }
+ catch (OperationCanceledException)
+ {
+ }
+
+ async Task LogProgress()
+ {
+ while (!source.Token.IsCancellationRequested)
+ {
+ await Task.Delay(1000);
+ Console.WriteLine($"Pumped {puts,-10} keys overall in {putIterations,3} iterations. ({numReaders})Readers got {hits,5} cache hits and {misses,5} misses.");
+ }
+ }
+
+ async Task Read()
+ {
+ var rnd = new Random();
+ while (!source.Token.IsCancellationRequested)
+ {
+ try
+ {
+ var value = cache.Get("key" + rnd.Next(0, maxItems));
+ if (value == null)
+ {
+ Interlocked.Increment(ref misses);
+ }
+ else
+ {
+ Interlocked.Increment(ref hits);
+ }
+ }
+ catch
+ {
+ // resuming if some timeouts happen
+ }
+
+ await Task.Delay(100, source.Token);
+ }
+ }
+ }
+
public static void PutAndMultiGetTest(params ICacheManager[] caches)
{
var swatch = Stopwatch.StartNew();
@@ -125,7 +214,7 @@ public static void PutAndMultiGetTest(params ICacheManager[] caches)
});
}
- Parallel.Invoke(new ParallelOptions() { MaxDegreeOfParallelism = 8 }, actions.ToArray());
+ Parallel.Invoke(new ParallelOptions() { MaxDegreeOfParallelism = 16 }, actions.ToArray());
}
var elapsed = swatch.ElapsedMilliseconds;
diff --git a/test/CacheManager.Config.Tests/cache.json b/benchmarks/CacheManager.Config.Tests/cache.json
similarity index 97%
rename from test/CacheManager.Config.Tests/cache.json
rename to benchmarks/CacheManager.Config.Tests/cache.json
index e773cfaa..28afbcbe 100644
--- a/test/CacheManager.Config.Tests/cache.json
+++ b/benchmarks/CacheManager.Config.Tests/cache.json
@@ -18,7 +18,7 @@
"maxRetries": 1000,
"name": "cachename",
"retryTimeout": 100,
- "updateMode": "Full",
+ "updateMode": "Up",
"backplane": {
"key": "redisConnection",
"knownType": "Redis",
diff --git a/test/CacheManager.Events.Tests/CacheEvent.cs b/benchmarks/CacheManager.Events.Tests/CacheEvent.cs
similarity index 100%
rename from test/CacheManager.Events.Tests/CacheEvent.cs
rename to benchmarks/CacheManager.Events.Tests/CacheEvent.cs
diff --git a/test/CacheManager.Events.Tests/CacheManager.Events.Tests.csproj b/benchmarks/CacheManager.Events.Tests/CacheManager.Events.Tests.csproj
similarity index 71%
rename from test/CacheManager.Events.Tests/CacheManager.Events.Tests.csproj
rename to benchmarks/CacheManager.Events.Tests/CacheManager.Events.Tests.csproj
index 14df05af..ea06c2cc 100644
--- a/test/CacheManager.Events.Tests/CacheManager.Events.Tests.csproj
+++ b/benchmarks/CacheManager.Events.Tests/CacheManager.Events.Tests.csproj
@@ -2,22 +2,22 @@
Exe
- net462
+ net8.0
+ false
-
-
+
+
-
+
-
\ No newline at end of file
diff --git a/test/CacheManager.Events.Tests/EventCommand.cs b/benchmarks/CacheManager.Events.Tests/EventCommand.cs
similarity index 99%
rename from test/CacheManager.Events.Tests/EventCommand.cs
rename to benchmarks/CacheManager.Events.Tests/EventCommand.cs
index c6f35a9c..a977f999 100644
--- a/test/CacheManager.Events.Tests/EventCommand.cs
+++ b/benchmarks/CacheManager.Events.Tests/EventCommand.cs
@@ -7,7 +7,7 @@
using System.Threading.Tasks;
using CacheManager.Core;
using CacheManager.Core.Internal;
-using Microsoft.Extensions.CommandLineUtils;
+using McMaster.Extensions.CommandLineUtils;
using Microsoft.Extensions.Logging;
namespace CacheManager.Events.Tests
@@ -163,4 +163,4 @@ private static IEnumerable GetStatus(EventCounter
+ {
+ c.AddConsole();
+ c.SetMinimumLevel(LogLevel.Warning);
+ });
+
+ var provider = services.BuildServiceProvider();
+ var loggerFactory = provider.GetRequiredService();
+
+ using var server = StartServer(loggerFactory);
+
+ var app = new CommandLineApplication();
+ app.Command("redis", (cmdApp) => new RedisCommand(cmdApp, loggerFactory));
+ app.Command("redisAndMemory", (cmdApp) => new RedisAndMemoryCommand(cmdApp, loggerFactory));
+ app.Command("redisAndMemoryNoMessages", (cmdApp) => new RedisAndMemoryNoMessagingCommand(cmdApp, loggerFactory));
+ app.Command("memoryOnly", (cmdApp) => new MemoryOnlyCommand(cmdApp, loggerFactory));
+ app.HelpOption("-h|--help");
+ if (args.Length == 0)
+ {
+ app.ShowHelp();
+ }
+
+ try
+ {
+ app.Execute(args);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
+ }
+}
diff --git a/test/CacheManager.Events.Tests/Properties/launchSettings.json b/benchmarks/CacheManager.Events.Tests/Properties/launchSettings.json
similarity index 62%
rename from test/CacheManager.Events.Tests/Properties/launchSettings.json
rename to benchmarks/CacheManager.Events.Tests/Properties/launchSettings.json
index a8986eb0..63b7de9b 100644
--- a/test/CacheManager.Events.Tests/Properties/launchSettings.json
+++ b/benchmarks/CacheManager.Events.Tests/Properties/launchSettings.json
@@ -2,7 +2,7 @@
"profiles": {
"CacheManager.Events.Tests": {
"commandName": "Project",
- "commandLineArgs": "redis -r 20 -j 10"
+ "commandLineArgs": "redisAndMemory -r 20 -j 10"
}
}
-}
\ No newline at end of file
+}
diff --git a/test/CacheManager.Events.Tests/RedisAndMemoryCommand.cs b/benchmarks/CacheManager.Events.Tests/RedisAndMemoryCommand.cs
similarity index 89%
rename from test/CacheManager.Events.Tests/RedisAndMemoryCommand.cs
rename to benchmarks/CacheManager.Events.Tests/RedisAndMemoryCommand.cs
index 5a550c18..47165ed9 100644
--- a/test/CacheManager.Events.Tests/RedisAndMemoryCommand.cs
+++ b/benchmarks/CacheManager.Events.Tests/RedisAndMemoryCommand.cs
@@ -2,7 +2,7 @@
using System.Threading.Tasks;
using CacheManager.Core;
using CacheManager.Core.Internal;
-using Microsoft.Extensions.CommandLineUtils;
+using McMaster.Extensions.CommandLineUtils;
using Microsoft.Extensions.Logging;
using StackExchange.Redis;
@@ -19,8 +19,7 @@ protected override void Configure()
base.Configure();
_multiplexer = ConnectionMultiplexer.Connect("127.0.0.1,allowAdmin=true");
- _configuration = new ConfigurationBuilder()
- .WithMicrosoftLogging(LoggerFactory)
+ _configuration = new CacheConfigurationBuilder()
.WithMicrosoftMemoryCacheHandle("in-memory")
.And
.WithJsonSerializer()
@@ -41,8 +40,7 @@ protected override void Configure()
base.Configure();
_multiplexer = ConnectionMultiplexer.Connect("127.0.0.1,allowAdmin=true");
- _configuration = new ConfigurationBuilder()
- .WithMicrosoftLogging(LoggerFactory)
+ _configuration = new CacheConfigurationBuilder()
.WithRedisBackplane("redisConfig")
.WithJsonSerializer()
.WithRedisConfiguration("redisConfig", _multiplexer, enableKeyspaceNotifications: true)
@@ -65,8 +63,7 @@ protected override void Configure()
base.Configure();
_multiplexer = ConnectionMultiplexer.Connect("127.0.0.1,allowAdmin=true");
- _configuration = new ConfigurationBuilder()
- .WithMicrosoftLogging(LoggerFactory)
+ _configuration = new CacheConfigurationBuilder()
.WithMicrosoftMemoryCacheHandle("in-memory")
.And
.WithRedisBackplane("redisConfig")
@@ -93,7 +90,7 @@ public override async Task Execute()
cacheA.TryUpdate(key, (oldVal) => oldVal + 1, out int? newValue);
- _multiplexer.GetDatabase(0).KeyDelete(key, CommandFlags.HighPriority);
+ _multiplexer.GetDatabase(0).KeyDelete(key);
await Task.Delay(0);
});
@@ -106,4 +103,4 @@ public override async Task Execute()
return 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/test/CacheManager.Events.Tests/Spinner.cs b/benchmarks/CacheManager.Events.Tests/Spinner.cs
similarity index 100%
rename from test/CacheManager.Events.Tests/Spinner.cs
rename to benchmarks/CacheManager.Events.Tests/Spinner.cs
diff --git a/samples/AspNetCore/Controllers/InfoController.cs b/samples/AspNetCore/Controllers/InfoController.cs
new file mode 100644
index 00000000..7d9e49af
--- /dev/null
+++ b/samples/AspNetCore/Controllers/InfoController.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Web.Controllers
+{
+ [Route("api/[controller]")]
+ public class InfoController : Controller
+ {
+ [HttpGet("")]
+ public IActionResult Index()
+ {
+ var result = new Dictionary();
+ result.Add(nameof(Microsoft.Extensions.Configuration), typeof(Microsoft.Extensions.Configuration.ConfigurationProvider).Assembly.GetName().Version.ToString());
+ result.Add(nameof(Microsoft.Extensions.Logging), typeof(Microsoft.Extensions.Logging.LoggerFactory).Assembly.GetName().Version.ToString());
+ result.Add(nameof(Microsoft.Extensions.Caching), typeof(Microsoft.Extensions.Caching.Memory.MemoryCache).Assembly.GetName().Version.ToString());
+ result.Add(nameof(Microsoft.Extensions.DependencyInjection), typeof(Microsoft.Extensions.DependencyInjection.ServiceProvider).Assembly.GetName().Version.ToString());
+ result.Add(nameof(Microsoft.Extensions.Options), typeof(Microsoft.Extensions.Options.Options).Assembly.GetName().Version.ToString());
+ result.Add(nameof(Microsoft.AspNetCore.Hosting), typeof(Microsoft.AspNetCore.Hosting.WebHostBuilder).Assembly.GetName().Version.ToString());
+
+ return Json(result);
+ }
+ }
+}
diff --git a/samples/AspnetCore.WebApp/Controllers/ValuesController.cs b/samples/AspNetCore/Controllers/ValuesController.cs
similarity index 91%
rename from samples/AspnetCore.WebApp/Controllers/ValuesController.cs
rename to samples/AspNetCore/Controllers/ValuesController.cs
index 8c16b9b0..923d7d4c 100644
--- a/samples/AspnetCore.WebApp/Controllers/ValuesController.cs
+++ b/samples/AspNetCore/Controllers/ValuesController.cs
@@ -10,12 +10,10 @@ public class ValuesController : Controller
{
private readonly ICacheManager _cache;
- public ValuesController(ICacheManager valuesCache, ICacheManager intCache, ICacheManager dates)
+ public ValuesController(ICacheManager valuesCache, ICacheManager nullableInts)
{
_cache = valuesCache;
-
- dates.Add("now", DateTime.UtcNow);
- intCache.Add("count", 1);
+ nullableInts.Add("key", 1);
}
// DELETE api/values/key
@@ -67,4 +65,4 @@ public IActionResult Put(string key, [FromBody]string value)
return NotFound();
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/AspNetCore/Program.cs b/samples/AspNetCore/Program.cs
new file mode 100644
index 00000000..a6a5beb2
--- /dev/null
+++ b/samples/AspNetCore/Program.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Linq;
+using System.Net;
+using Garnet;
+using Garnet.server;
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace AspnetCore.WebApp;
+
+public class Program
+{
+ public static GarnetServer StartServer(ILoggerFactory loggerFactory = null)
+ {
+ var server = new GarnetServer(new GarnetServerOptions()
+ {
+ EnableLua = true,
+ LuaOptions = new LuaOptions(LuaMemoryManagementMode.Native, string.Empty, TimeSpan.FromSeconds(5)),
+ EndPoint = new IPEndPoint(IPAddress.Loopback, 6379)
+ },
+ loggerFactory: loggerFactory);
+
+ server.Start();
+
+ return server;
+ }
+
+ public static void Main(string[] args)
+ {
+ using var server = StartServer();
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IWebHostBuilder CreateHostBuilder(string[] args) =>
+ WebHost.CreateDefaultBuilder(args)
+ .UseStartup()
+ .ConfigureAppConfiguration((ctx, builder) =>
+ {
+ builder.AddJsonFile("cache.json", optional: false);
+ });
+}
diff --git a/samples/AspNetCore/Properties/launchSettings.json b/samples/AspNetCore/Properties/launchSettings.json
new file mode 100644
index 00000000..730e96ba
--- /dev/null
+++ b/samples/AspNetCore/Properties/launchSettings.json
@@ -0,0 +1,13 @@
+{
+ "profiles": {
+ "AspnetCore.WebApp": {
+ "commandName": "Project",
+ "launchBrowser": false,
+ "launchUrl": "http://localhost:5000/swagger/ui",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "http://localhost:5000"
+ }
+ }
+}
diff --git a/samples/AspNetCore/Startup.cs b/samples/AspNetCore/Startup.cs
new file mode 100644
index 00000000..f311a67e
--- /dev/null
+++ b/samples/AspNetCore/Startup.cs
@@ -0,0 +1,101 @@
+namespace AspnetCore.WebApp
+{
+ using System;
+ using CacheManager.Core;
+ using Microsoft.AspNetCore.Builder;
+ using Microsoft.AspNetCore.Hosting;
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.Extensions.DependencyInjection;
+ using Microsoft.Extensions.Logging;
+ using Microsoft.Extensions.Configuration;
+ using Microsoft.Extensions.Hosting;
+
+ public class Startup
+ {
+ public Startup(IWebHostEnvironment env, IConfiguration configuration, ILoggerFactory loggerFactory)
+ {
+ HostingEnvironment = env ?? throw new ArgumentNullException(nameof(env));
+ Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
+ LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
+ }
+
+ public IWebHostEnvironment HostingEnvironment { get; }
+
+ public IConfiguration Configuration { get; }
+
+ public ILoggerFactory LoggerFactory { get; }
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddMvc();
+
+ services.AddSwaggerGen(c =>
+ {
+ c.SwaggerDoc("v1",
+ new Microsoft.OpenApi.Models.OpenApiInfo
+ {
+ Title = "My API - V1",
+ Version = "v1"
+ }
+ );
+ });
+
+ // uses a refined configuration (this will not log, as we added the MS Logger only to the configuration above
+ services.AddCacheManagerConfiguration(Configuration, configure: builder => builder
+ .WithJsonSerializer()
+ .WithRedisConfiguration("redis", c => c.WithEndpoint("localhost", 6379))
+ .WithRedisCacheHandle("redis"));
+
+ // creates a completely new configuration for this instance (also not logging)
+ services.AddCacheManager(inline => inline.WithDictionaryHandle());
+
+ // any other type will be this. Configuration used will be the one defined by AddCacheManagerConfiguration earlier.
+ services.AddCacheManager();
+ }
+
+ public void Configure(IApplicationBuilder app)
+ {
+ // give some error details in debug mode
+ if (HostingEnvironment.IsDevelopment())
+ {
+ app.Use(async (ctx, next) =>
+ {
+ try
+ {
+ await next.Invoke();
+ }
+ catch (Exception ex)
+ {
+ await ctx.Response.WriteAsync($"{{\"error\": \"{ex}\"}}");
+ }
+ });
+ }
+
+ // lets redirect to the swagger UI, there is nothing else to display otherwise ;)
+ app.Use(async (ctx, next) =>
+ {
+ if (ctx.Request.Path.StartsWithSegments("/"))
+ {
+ ctx.Response.Redirect("/swagger/");
+ }
+ else
+ {
+ await next.Invoke();
+ }
+ });
+
+ app.UseStaticFiles();
+ app.UseRouting();
+ app.UseCors();
+ app.UseAuthentication();
+ app.UseAuthorization();
+ app.UseEndpoints(b => b.MapControllers());
+
+ app.UseSwagger();
+ app.UseSwaggerUI(c =>
+ {
+ c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
+ });
+ }
+ }
+}
diff --git a/samples/AspNetCore/Web.csproj b/samples/AspNetCore/Web.csproj
new file mode 100644
index 00000000..97eacf8c
--- /dev/null
+++ b/samples/AspNetCore/Web.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net8.0
+ true
+ AspnetCore.WebApp
+ Exe
+ AspnetCore.WebApp
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/AspnetCore.WebApp/appsettings.json b/samples/AspNetCore/appsettings.json
similarity index 68%
rename from samples/AspnetCore.WebApp/appsettings.json
rename to samples/AspNetCore/appsettings.json
index bd260c7a..7efae0d9 100644
--- a/samples/AspnetCore.WebApp/appsettings.json
+++ b/samples/AspNetCore/appsettings.json
@@ -1,9 +1,8 @@
{
"Logging": {
- "IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
- "CacheManager": "Debug",
+ "CacheManager": "Trace",
"System": "Error",
"Microsoft": "Error"
}
diff --git a/samples/AspnetCore.WebApp/cache.json b/samples/AspNetCore/cache.json
similarity index 100%
rename from samples/AspnetCore.WebApp/cache.json
rename to samples/AspNetCore/cache.json
diff --git a/samples/AspnetCore.WebApp/web.config b/samples/AspNetCore/web.config
similarity index 100%
rename from samples/AspnetCore.WebApp/web.config
rename to samples/AspNetCore/web.config
diff --git a/samples/AspnetCore.WebApp/AspnetCore.WebApp.csproj b/samples/AspnetCore.WebApp/AspnetCore.WebApp.csproj
deleted file mode 100644
index 8ab25c3d..00000000
--- a/samples/AspnetCore.WebApp/AspnetCore.WebApp.csproj
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
- netcoreapp1.0
- true
- AspnetCore.WebApp
- Exe
- AspnetCore.WebApp
- 1.1.1
-
-
-
-
- PreserveNewest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/AspnetCore.WebApp/Program.cs b/samples/AspnetCore.WebApp/Program.cs
deleted file mode 100644
index 1b58aeb7..00000000
--- a/samples/AspnetCore.WebApp/Program.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-
-namespace AspnetCore.WebApp
-{
- public class Program
- {
- public static void Main(string[] args)
- {
- var host = new WebHostBuilder()
- .UseKestrel()
- .UseContentRoot(Directory.GetCurrentDirectory())
- .UseIISIntegration()
- .UseStartup()
- .Build();
-
- host.Run();
- }
- }
-}
\ No newline at end of file
diff --git a/samples/AspnetCore.WebApp/Properties/launchSettings.json b/samples/AspnetCore.WebApp/Properties/launchSettings.json
deleted file mode 100644
index 2d46cd93..00000000
--- a/samples/AspnetCore.WebApp/Properties/launchSettings.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:58186",
- "sslPort": 0
- }
- },
- "profiles": {
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": false,
- "launchUrl": "/swagger/ui",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "AspnetCore.WebApp": {
- "commandName": "Project",
- "launchBrowser": false,
- "launchUrl": "http://localhost:5000/swagger/ui",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "http://localhost:5000"
- }
- }
-}
\ No newline at end of file
diff --git a/samples/AspnetCore.WebApp/Startup.cs b/samples/AspnetCore.WebApp/Startup.cs
deleted file mode 100644
index 5d3a8d00..00000000
--- a/samples/AspnetCore.WebApp/Startup.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.Linq;
-using CacheManager.Core;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-
-namespace AspnetCore.WebApp
-{
- using Microsoft.Extensions.Configuration;
-
- public class Startup
- {
- public Startup(IHostingEnvironment env)
- {
- var builder = new ConfigurationBuilder()
- .SetBasePath(env.ContentRootPath)
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
- // adding cache.json which contains cachemanager configuration(s)
- .AddJsonFile("cache.json", optional: false)
- .AddEnvironmentVariables();
-
- Configuration = builder.Build();
- }
-
- public IConfigurationRoot Configuration { get; }
-
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddMvc();
- services.AddSwaggerGen();
-
- // using the new overload which adds a singleton of the configuration to services and the configure method to add logging
- // TODO: still not 100% happy with the logging part
- services.AddCacheManagerConfiguration(Configuration, cfg => cfg.WithMicrosoftLogging(services));
-
- // uses a refined configurastion (this will not log, as we added the MS Logger only to the configuration above
- services.AddCacheManager(Configuration, configure: builder => builder.WithJsonSerializer());
-
- // creates a completely new configuration for this instance (also not logging)
- services.AddCacheManager(inline => inline.WithDictionaryHandle());
-
- // any other type will be this. Configurastion used will be the one defined by AddCacheManagerConfiguration earlier.
- services.AddCacheManager();
- }
-
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
- {
- // add console logging with the configured log levels from appsettings.json
- loggerFactory.AddConsole(Configuration.GetSection("Logging"));
-
- // give some error details in debug mode
- if (env.IsDevelopment())
- {
- app.Use(async (ctx, next) =>
- {
- try
- {
- await next.Invoke();
- }
- catch (Exception ex)
- {
- await ctx.Response.WriteAsync($"{{\"error\": \"{ex}\"}}");
- }
- });
- }
-
- // lets redirect to the swagger ui, there is nothing else to display otherwise ;)
- app.Use(async (ctx, next) =>
- {
- if (ctx.Request.Path.StartsWithSegments("/"))
- {
- ctx.Response.Redirect("/swagger/ui");
- }
- else
- {
- await next.Invoke();
- }
- });
-
- //app.UseStaticFiles();
- app.UseMvc();
-
- app.UseSwagger();
- app.UseSwaggerUi();
- }
- }
-}
\ No newline at end of file
diff --git a/samples/CacheManager.Examples.Configuration/Couchbase.cs b/samples/CacheManager.Examples.Configuration/Couchbase.cs
deleted file mode 100644
index 75eb40b4..00000000
--- a/samples/CacheManager.Examples.Configuration/Couchbase.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-using System.Collections.Generic;
-using CacheManager.Core;
-using Couchbase;
-using Couchbase.Authentication;
-using Couchbase.Configuration.Client;
-
-namespace Configuration
-{
- public class Couchbase
- {
- public void UsingClusterHelper()
- {
- var cfg = new ClientConfiguration()
- {
- Servers = new List()
- {
- new Uri("http://127.0.0.1:8091")
- }
- };
-
- ClusterHelper.Initialize(cfg);
- ClusterHelper.Get().Authenticate(new PasswordAuthenticator("admin", "password"));
-
- // using cluster helper is enough for CacheManager since 1.0.2 as it falls back to ClusterHelper internally
- var cacheConfig = new ConfigurationBuilder()
- .WithCouchbaseCacheHandle("cb")
- .Build();
-
- var cache = new BaseCacheManager(cacheConfig);
- cache.AddOrUpdate("test", 1, (v) => v + 1);
- }
-
- public void UsingAppConfig()
- {
- // see couchbaseClients/couchbase section in app.config of this project
- var cacheConfig = new ConfigurationBuilder()
- .WithCouchbaseCacheHandle("couchbaseClients/couchbase")
- .Build();
-
- var cache = new BaseCacheManager(cacheConfig);
- cache.AddOrUpdate("test", 1, (v) => v + 1);
- }
-
- public void UsingAppConfigWithAuthentication()
- {
- // see couchbaseClients/couchbase section in app.config of this project
- // Note: even though we pass in "cb", CacheManager will fall back to the
- // default couchbase section at couchbaseClients/couchbase!
- // We could also pass in the section name explicitly instead of "cb".
-
- ClusterHelper.Initialize("couchbaseClients/couchbase");
- ClusterHelper.Get().Authenticate(new PasswordAuthenticator("admin", "password"));
-
- var cacheConfig = new ConfigurationBuilder()
- .WithCouchbaseCacheHandle("keydoesnotmatter")
- .Build();
-
- var cache = new BaseCacheManager(cacheConfig);
- cache.AddOrUpdate("test", 1, (v) => v + 1);
- }
-
- public void UsingClientConfiguration()
- {
- var cacheConfig = new ConfigurationBuilder()
- .WithCouchbaseConfiguration("myConfig", new ClientConfiguration()) // add the configuration you need here...
- .WithCouchbaseCacheHandle("myConfig")
- .Build();
- }
-
- public void UsingAlreadyDefinedCluster()
- {
- var cluster = new Cluster(new ClientConfiguration());
- cluster.Authenticate(new PasswordAuthenticator("admin", "password"));
-
- var cacheConfig = new ConfigurationBuilder()
- .WithCouchbaseCluster("myCluster", cluster)
- .WithCouchbaseCacheHandle("myCluster")
- .Build();
- }
-
- public void UsingExplicitBucketName()
- {
- ClusterHelper.Initialize();
- ClusterHelper.Get().Authenticate(new PasswordAuthenticator("admin", "password"));
-
- var cacheConfig = new ConfigurationBuilder()
- .WithCouchbaseCacheHandle("keydoesnotmatter", "beer-sample") // passing in a bucket name which should be used
- .Build();
-
- var cache = new BaseCacheManager(cacheConfig);
- cache.AddOrUpdate("test", 1, (v) => v + 1);
- }
-
- public void UsingExplicitBucketNameWithPassword()
- {
- var cacheConfig = new ConfigurationBuilder()
- .WithCouchbaseConfiguration("cb", new ClientConfiguration())
- .WithCouchbaseCacheHandle("cb", "secret-bucket", "secret") // passing in a bucket-name and bucket-password
- .Build();
-
- var cache = new BaseCacheManager(cacheConfig);
- cache.AddOrUpdate("test", 1, (v) => v + 1);
- }
- }
-}
\ No newline at end of file
diff --git a/samples/CacheManager.Examples.Configuration/Program.cs b/samples/CacheManager.Examples.Configuration/Program.cs
deleted file mode 100644
index 4677b0c4..00000000
--- a/samples/CacheManager.Examples.Configuration/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-
-namespace Configuration
-{
- class Program
- {
- static void Main(string[] args)
- {
- //var cb = new Couchbase();
- //cb.UsingClusterHelper();
- //cb.UsingAppConfig();
- //cb.UsingAppConfigWithAuthentication();
- //cb.UsingExplicitBucketName();
- //cb.UsingExplicitBucketNameWithPassword();
- }
- }
-}
\ No newline at end of file
diff --git a/samples/CacheManager.Examples.Configuration/app.config b/samples/CacheManager.Examples.Configuration/app.config
deleted file mode 100644
index 1a94b5f2..00000000
--- a/samples/CacheManager.Examples.Configuration/app.config
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/CacheManager.Examples/App.config b/samples/CacheManager.Examples/App.config
index 2a2a36c0..c901d07c 100644
--- a/samples/CacheManager.Examples/App.config
+++ b/samples/CacheManager.Examples/App.config
@@ -10,7 +10,7 @@
-
+
diff --git a/samples/CacheManager.Examples/CacheManager.Examples.csproj b/samples/CacheManager.Examples/CacheManager.Examples.csproj
index 550dfb58..4ea3b89a 100644
--- a/samples/CacheManager.Examples/CacheManager.Examples.csproj
+++ b/samples/CacheManager.Examples/CacheManager.Examples.csproj
@@ -3,7 +3,7 @@
CacheManager.Examples Console Application
MICHA
- net451
+ net8.0
CacheManager.Examples
Exe
CacheManager.Examples
@@ -13,6 +13,7 @@
false
false
false
+ false
@@ -22,21 +23,13 @@
-
-
-
-
-
-
+
-
-
-
+
-
-
+
\ No newline at end of file
diff --git a/samples/CacheManager.Examples/Program.cs b/samples/CacheManager.Examples/Program.cs
index 358eeda1..3752d825 100644
--- a/samples/CacheManager.Examples/Program.cs
+++ b/samples/CacheManager.Examples/Program.cs
@@ -2,363 +2,311 @@
using System.Threading;
using CacheManager.Core;
using Microsoft.Extensions.Logging;
-#if NET451
-using Microsoft.Practices.Unity;
-#else
-using Unity;
-#endif
+using Microsoft.Extensions.DependencyInjection;
+using System.Net;
+using Garnet.server;
+using Garnet;
-namespace CacheManager.Examples
+namespace CacheManager.Examples;
+
+public class Program
{
- public class Program
+ public static GarnetServer StartServer(ILoggerFactory loggerFactory = null)
{
- private static void Main()
+ var server = new GarnetServer(new GarnetServerOptions()
{
- EventsExample();
- UnityInjectionExample();
- UnityInjectionExample_Advanced();
- SimpleCustomBuildConfigurationUsingConfigBuilder();
- SimpleCustomBuildConfigurationUsingFactory();
- UpdateTest();
- UpdateCounterTest();
- LoggingSample();
- }
+ EnableLua = true,
+ LuaOptions = new LuaOptions(LuaMemoryManagementMode.Native, string.Empty, TimeSpan.FromSeconds(5)),
+ EndPoint = new IPEndPoint(IPAddress.Loopback, 6379)
+ },
+ loggerFactory: loggerFactory);
-#if !NETCOREAPP
+ server.Start();
- private static void MostSimpleCacheManager()
- {
- var config = new ConfigurationBuilder()
- .WithSystemRuntimeCacheHandle()
- .Build();
+ return server;
+ }
- var cache = new BaseCacheManager(config);
- // or
- var cache2 = CacheFactory.FromConfiguration(config);
- }
+ private static void Main()
+ {
+ using var server = StartServer();
+ EventsExample();
+ MostSimpleCacheManagerWithLogging();
+ SimpleCustomBuildConfigurationUsingConfigBuilder();
+ SimpleCustomBuildConfigurationUsingFactory();
+ UpdateTest();
+ UpdateCounterTest();
+ LoggingSample();
+ }
- private static void MostSimpleCacheManagerB()
- {
- var cache = new BaseCacheManager(
- new CacheManagerConfiguration()
- .Builder
- .WithSystemRuntimeCacheHandle()
- .Build());
- }
+ private static void MostSimpleCacheManager()
+ {
+ var config = new CacheConfigurationBuilder()
+ .WithSystemRuntimeCacheHandle()
+ .Build();
- private static void MostSimpleCacheManagerC()
- {
- var cache = CacheFactory.Build(
- p => p.WithSystemRuntimeCacheHandle());
- }
+ var cache = new BaseCacheManager(config);
+ // or
+ var cache2 = CacheFactory.FromConfiguration(config);
+ }
- private static void MostSimpleCacheManagerWithLogging()
- {
- var config = new ConfigurationBuilder()
- .WithMicrosoftLogging(l => l.AddConsole(LogLevel.Information))
+ private static void MostSimpleCacheManagerB()
+ {
+ var cache = new BaseCacheManager(
+ new CacheManagerConfiguration()
+ .Builder
.WithSystemRuntimeCacheHandle()
- .Build();
+ .Build());
+ }
- var cache = new BaseCacheManager(config);
- // or
- var cache2 = CacheFactory.FromConfiguration(config);
- }
+ private static void MostSimpleCacheManagerC()
+ {
+ var cache = CacheFactory.Build(
+ p => p.WithSystemRuntimeCacheHandle());
+ }
- private static void EditExistingConfiguration()
- {
- var config = new ConfigurationBuilder()
- .WithSystemRuntimeCacheHandle()
- .EnableStatistics()
- .Build();
+ private static void MostSimpleCacheManagerWithLogging()
+ {
+ var services = new ServiceCollection();
+ services.AddLogging(c => c.AddConsole().SetMinimumLevel(LogLevel.Trace));
+ var loggerFactory = services.BuildServiceProvider().GetService();
- config = new ConfigurationBuilder(config)
- .WithMicrosoftLogging(f => f.AddConsole())
- .Build();
- }
+ var config = new CacheConfigurationBuilder()
+ .WithSystemRuntimeCacheHandle()
+ .Build();
-#endif
+ ICacheManager cache = new BaseCacheManager(config, loggerFactory);
+ cache.Add("test", "test");
+ cache.Exists("test no");
+ cache.Remove("test");
- private static void LoggingSample()
- {
- var cache = CacheFactory.Build(
- c =>
- c.WithMicrosoftLogging(log =>
- {
- log.AddConsole(LogLevel.Trace);
- })
- .WithDictionaryHandle()
- .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromSeconds(10)));
+ // or
+ cache = CacheFactory.FromConfiguration(config, loggerFactory);
- cache.AddOrUpdate("myKey", "someregion", "value", _ => "new value");
- cache.AddOrUpdate("myKey", "someregion", "value", _ => "new value");
- cache.Expire("myKey", "someregion", TimeSpan.FromMinutes(10));
- var val = cache.Get("myKey", "someregion");
- }
+ cache.Add("test", "test");
+ cache.Exists("test no");
+ cache.Remove("test");
+ }
-#if !NETCOREAPP
+ private static void EditExistingConfiguration()
+ {
+ var config = new CacheConfigurationBuilder()
+ .WithSystemRuntimeCacheHandle()
+ .EnableStatistics()
+ .Build();
- private static void AppConfigLoadInstalledCacheCfg()
- {
- var cache = CacheFactory.FromConfiguration