Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 11, 2024
2 parents 6b6ca4b + cc52acf commit 0c76834
Show file tree
Hide file tree
Showing 17 changed files with 153 additions and 12 deletions.
21 changes: 14 additions & 7 deletions NewLife.Redis.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{E136AE06-927B-4D10-BB83-B607ED0B1FD4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QueueDemo", "QueueDemo\QueueDemo.csproj", "{5829188A-DC4A-4F00-AD95-5873E4057BDE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewLife.Redis.Extensions", "NewLife.Redis.Extensions\NewLife.Redis.Extensions.csproj", "{499A9E8E-050C-40CD-90AF-FE4E499121D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QueueDemo", "Samples\QueueDemo\QueueDemo.csproj", "{AC75EE22-B722-418F-A2A7-66020E29FE4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmark", "Samples\Benchmark\Benchmark.csproj", "{FAC752B8-087D-44A9-88E8-3B759A72F936}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -42,20 +44,25 @@ Global
{08A39462-0531-45AB-ACBB-03F62AF4400F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08A39462-0531-45AB-ACBB-03F62AF4400F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08A39462-0531-45AB-ACBB-03F62AF4400F}.Release|Any CPU.Build.0 = Release|Any CPU
{5829188A-DC4A-4F00-AD95-5873E4057BDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5829188A-DC4A-4F00-AD95-5873E4057BDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5829188A-DC4A-4F00-AD95-5873E4057BDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5829188A-DC4A-4F00-AD95-5873E4057BDE}.Release|Any CPU.Build.0 = Release|Any CPU
{499A9E8E-050C-40CD-90AF-FE4E499121D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{499A9E8E-050C-40CD-90AF-FE4E499121D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{499A9E8E-050C-40CD-90AF-FE4E499121D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{499A9E8E-050C-40CD-90AF-FE4E499121D1}.Release|Any CPU.Build.0 = Release|Any CPU
{AC75EE22-B722-418F-A2A7-66020E29FE4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC75EE22-B722-418F-A2A7-66020E29FE4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC75EE22-B722-418F-A2A7-66020E29FE4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC75EE22-B722-418F-A2A7-66020E29FE4C}.Release|Any CPU.Build.0 = Release|Any CPU
{FAC752B8-087D-44A9-88E8-3B759A72F936}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAC752B8-087D-44A9-88E8-3B759A72F936}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAC752B8-087D-44A9-88E8-3B759A72F936}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAC752B8-087D-44A9-88E8-3B759A72F936}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5829188A-DC4A-4F00-AD95-5873E4057BDE} = {E136AE06-927B-4D10-BB83-B607ED0B1FD4}
{AC75EE22-B722-418F-A2A7-66020E29FE4C} = {E136AE06-927B-4D10-BB83-B607ED0B1FD4}
{FAC752B8-087D-44A9-88E8-3B759A72F936} = {E136AE06-927B-4D10-BB83-B607ED0B1FD4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {323831A1-A95B-40AB-B9AD-36A0BC10C2CB}
Expand Down
2 changes: 1 addition & 1 deletion NewLife.Redis/NewLife.Redis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.1.2024.1205" />
<PackageReference Include="NewLife.Core" Version="11.1.2024.1206" />
</ItemGroup>

<ItemGroup>
Expand Down
59 changes: 59 additions & 0 deletions Samples/Benchmark/BasicBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Security.Cryptography;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using NewLife.Caching;
using NewLife.Security;

namespace Benchmark;

[SimpleJob(RunStrategy.ColdStart, iterationCount: 1)]
[MemoryDiagnoser]
public class BasicBenchmark
{
public FullRedis Redis { get; set; }

private String[] _keys;

[GlobalSetup]
public void Setup()
{
var rds = new FullRedis
{
Tracer = DefaultTracer.Instance,
Log = XTrace.Log,
};
rds.Init("server=127.0.0.1:6379;password=;db=3;timeout=5000");

Redis = rds;

var ks = new String[100_000];
for (var i = 0; i < ks.Length; i++)
{
ks[i] = Rand.NextString(16);
}
_keys = ks;
}

[Benchmark]
public void GetTest()
{
var rds = Redis;

for (var i = 0; i < _keys.Length; i++)
{
var value = rds.Get<String>(_keys[i]);
}
}

[Benchmark]
public void SetTest()
{
var rds = Redis;
var value = Rand.NextString(16);

for (var i = 0; i < _keys.Length; i++)
{
rds.Set(_keys[i], value);
}
}
}
33 changes: 33 additions & 0 deletions Samples/Benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AssemblyTitle>应用后台任务</AssemblyTitle>
<Description>数据处理、定时任务、MQ生产消费、系统监控等超长独立工作的后台任务</Description>
<Company>新生命开发团队</Company>
<Copyright>©2002-2024 NewLife</Copyright>
<VersionPrefix>1.0</VersionPrefix>
<VersionSuffix>$([System.DateTime]::Now.ToString(`yyyy.MMdd`))</VersionSuffix>
<Version>$(VersionPrefix).$(VersionSuffix)</Version>
<FileVersion>$(Version)</FileVersion>
<OutputPath>..\..\Bin\Benchmark</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Using Include="NewLife" />
<Using Include="NewLife.Log" />
<Using Include="NewLife.Model" />
<Using Include="NewLife.Reflection" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="NewLife.Stardust" Version="3.2.2024.1211" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\NewLife.Redis\NewLife.Redis.csproj" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions Samples/Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Benchmark;
using BenchmarkDotNet.Running;
using NewLife.Caching;
using Stardust;

//!!! 标准后台服务项目模板,新生命团队强烈推荐

// 启用控制台日志,拦截所有异常
XTrace.UseConsole();

// 初始化对象容器,提供依赖注入能力
var services = ObjectContainer.Current;
services.AddSingleton(XTrace.Log);

// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址
var star = services.AddStardust();

var summary = BenchmarkRunner.Run<BasicBenchmark>();

Console.ReadLine();
22 changes: 22 additions & 0 deletions Samples/Benchmark/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
//"StarServer": "http://s.newlifex.com:6600",
//"RedisCache": "server=127.0.0.1:6379;password=;db=3",
//"RedisQueue": "server=127.0.0.1:6379;password=;db=5",
"ConnectionStrings": {
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite"

// 各种数据库连接字符串模版,连接名Zero对应Zero.Data/Projects/Model.xml中的ConnName
//"Zero": "Server=.;Port=3306;Database=zero;Uid=root;Pwd=root;Provider=MySql",
//"Zero": "Data Source=.;Initial Catalog=zero;user=sa;password=sa;Provider=SqlServer",
//"Zero": "Server=.;Database=zero;Uid=root;Pwd=root;Provider=PostgreSql",
//"Zero": "Data Source=Tcp://127.0.0.1/ORCL;User Id=scott;Password=tiger;Provider=Oracle"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<TargetFramework>net8.0</TargetFramework>
<AssemblyVersion>1.0.*</AssemblyVersion>
<Deterministic>false</Deterministic>
<OutputPath>..\Bin\QueueDemo</OutputPath>
<OutputPath>..\..\Bin\QueueDemo</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NewLife.Redis\NewLife.Redis.csproj" />
<ProjectReference Include="..\..\NewLife.Redis\NewLife.Redis.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.1.2024.1205" />
<PackageReference Include="NewLife.Core" Version="11.1.2024.1206" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest/XUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NewLife.Core" Version="11.1.2024.1205" />
<PackageReference Include="NewLife.Core" Version="11.1.2024.1206" />
<PackageReference Include="NewLife.UnitTest" Version="1.0.2024.1006" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down

0 comments on commit 0c76834

Please sign in to comment.