Skip to content

Commit

Permalink
v1.0.1 add Async methods
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Sep 7, 2022
1 parent e0ca0cc commit e711e75
Show file tree
Hide file tree
Showing 17 changed files with 2,537 additions and 759 deletions.
143 changes: 92 additions & 51 deletions examples/console_netcore31_vs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ static void Main(string[] args)
var tasks = new List<Task>();
var results = new ConcurrentQueue<string>();

//cli.FlushDb();
//results.Clear();
//sw.Reset();
//sw.Start();
//for (var a = 0; a < 100000; a++)
//{
// var tmp = Guid.NewGuid().ToString();
// sedb.StringSet(tmp, String);
// var val = sedb.StringGet(tmp);
// if (val != String) throw new Exception("not equal");
// results.Enqueue(val);
//}
//sw.Stop();
//Console.WriteLine("StackExchange(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
//tasks.Clear();
//results.Clear();
//cli.FlushDb();
cli.FlushDb();
results.Clear();
sw.Reset();
sw.Start();
for (var a = 0; a < 10000; a++)
{
var tmp = Guid.NewGuid().ToString();
sedb.StringSet(tmp, String);
var val = sedb.StringGet(tmp);
if (val != String) throw new Exception("not equal");
results.Enqueue(val);
}
sw.Stop();
Console.WriteLine("StackExchange(0-10000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
tasks.Clear();
results.Clear();
cli.FlushDb();

//sw.Reset();
//sw.Start();
Expand All @@ -95,24 +95,24 @@ static void Main(string[] args)
//results.Clear();
//cli.FlushDb();

//sw.Reset();
//sw.Start();
//Task.Run(async () =>
//{
// for (var a = 0; a < 100000; a++)
// {
// var tmp = Guid.NewGuid().ToString();
// await sedb.StringSetAsync(tmp, String);
// var val = await sedb.StringGetAsync(tmp);
// if (val != String) throw new Exception("not equal");
// results.Enqueue(val);
// }
//}).Wait();
//sw.Stop();
//Console.WriteLine("StackExchangeAsync(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
//tasks.Clear();
//results.Clear();
//cli.FlushDb();
sw.Reset();
sw.Start();
Task.Run(async () =>
{
for (var a = 0; a < 10000; a++)
{
var tmp = Guid.NewGuid().ToString();
await sedb.StringSetAsync(tmp, String);
var val = await sedb.StringGetAsync(tmp);
if (val != String) throw new Exception("not equal");
results.Enqueue(val);
}
}).Wait();
sw.Stop();
Console.WriteLine("StackExchangeAsync(0-10000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
tasks.Clear();
results.Clear();
cli.FlushDb();

sw.Reset();
sw.Start();
Expand All @@ -136,21 +136,21 @@ static void Main(string[] args)
cli.FlushDb();


//sw.Reset();
//sw.Start();
//for (var a = 0; a < 100000; a++)
//{
// var tmp = Guid.NewGuid().ToString();
// cli.Set(tmp, String);
// var val = cli.Get(tmp);
// if (val != String) throw new Exception("not equal");
// results.Enqueue(val);
//}
//sw.Stop();
//Console.WriteLine("FreeRedis(0-100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
//tasks.Clear();
//results.Clear();
//cli.FlushDb();
sw.Reset();
sw.Start();
for (var a = 0; a < 10000; a++)
{
var tmp = Guid.NewGuid().ToString();
cli.Set(tmp, String);
var val = cli.Get(tmp);
if (val != String) throw new Exception("not equal");
results.Enqueue(val);
}
sw.Stop();
Console.WriteLine("FreeRedisSync(0-10000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
tasks.Clear();
results.Clear();
cli.FlushDb();

sw.Reset();
sw.Start();
Expand All @@ -168,7 +168,48 @@ static void Main(string[] args)
}
Task.WaitAll(tasks.ToArray());
sw.Stop();
Console.WriteLine("FreeRedis(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
Console.WriteLine("FreeRedisSync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
tasks.Clear();
results.Clear();
cli.FlushDb();


sw.Reset();
sw.Start();
Task.Run(async () =>
{
for (var a = 0; a < 10000; a++)
{
var tmp = Guid.NewGuid().ToString();
await cli.SetAsync(tmp, String);
var val = await cli.GetAsync(tmp);
if (val != String) throw new Exception("not equal");
results.Enqueue(val);
}
}).Wait();
sw.Stop();
Console.WriteLine("FreeRedisAsync(0-10000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
tasks.Clear();
results.Clear();
cli.FlushDb();

sw.Reset();
sw.Start();
tasks = new List<Task>();
for (var a = 0; a < 100000; a++)
{
tasks.Add(Task.Run(async () =>
{
var tmp = Guid.NewGuid().ToString();
await cli.SetAsync(tmp, String);
var val = await cli.GetAsync(tmp);
if (val != String) throw new Exception("not equal");
results.Enqueue(val);
}));
}
Task.WaitAll(tasks.ToArray());
sw.Stop();
Console.WriteLine("FreeRedisAsync(Task.WaitAll 100000): " + sw.ElapsedMilliseconds + "ms results: " + results.Count);
tasks.Clear();
results.Clear();
cli.FlushDb();
Expand Down
6 changes: 3 additions & 3 deletions src/FreeRedis/FreeRedis.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net50;netstandard2.1;netstandard2.0;net451;net40</TargetFrameworks>
<TargetFrameworks>net60;netstandard2.1;netstandard2.0;net451;net40</TargetFrameworks>
<AssemblyName>FreeRedis</AssemblyName>
<PackageId>FreeRedis</PackageId>
<RootNamespace>FreeRedis</RootNamespace>
<Version>0.6.6</Version>
<Version>1.0.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/2881099/FreeRedis</PackageProjectUrl>
<Description>FreeRedis is .NET redis client, supports cluster, sentinel, master-slave, pipeline, transaction and connection pool.</Description>
Expand All @@ -32,7 +32,7 @@
<DefineConstants>net40</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net40'">
<DefineConstants>isasync_close</DefineConstants>
<DefineConstants>isasync</DefineConstants>
</PropertyGroup>

</Project>
Loading

0 comments on commit e711e75

Please sign in to comment.