v2.0.2018.0829 全面扩充常用指令,日均80亿次调用量
This commit is contained in:
parent
62946f2078
commit
4c85f1e668
Binary file not shown.
Binary file not shown.
14201
DLL/NewLife.Core.xml
14201
DLL/NewLife.Core.xml
File diff suppressed because it is too large
Load Diff
BIN
DLL/nuget.exe
BIN
DLL/nuget.exe
Binary file not shown.
49
DLL/更新DLL.cs
49
DLL/更新DLL.cs
|
@ -1,49 +0,0 @@
|
|||
// 自动选择最新的文件源
|
||||
var srcs = new String[] { @"..\Bin", @"C:\X\DLL", @"C:\X\Bin", @"D:\X\Bin", @"E:\X\DLL", @"E:\X\Bin" };
|
||||
var cur = ".".GetFullPath();
|
||||
foreach (var item in srcs)
|
||||
{
|
||||
// 跳过当前目录
|
||||
if (item.EqualIgnoreCase(cur)) continue;
|
||||
|
||||
Console.WriteLine("复制 {0} => {1}", item, cur);
|
||||
|
||||
try
|
||||
{
|
||||
item.AsDirectory().CopyToIfNewer(cur, "*.dll;*.exe;*.xml;*.pdb", false,
|
||||
name => Console.WriteLine("\t{1}\t{0}", name, item.CombinePath(name).AsFile().LastWriteTime.ToFullString()));
|
||||
}
|
||||
catch (Exception ex) { Console.WriteLine(" " + ex.Message); }
|
||||
}
|
||||
srcs = new String[] { @"..\..\WsLink.Token\Bin", @"..\..\WsLink.Token\DLL", @"..\..\WsLink.Master\Bin" };
|
||||
cur = ".".GetFullPath();
|
||||
foreach (var item in srcs)
|
||||
{
|
||||
// 跳过当前目录
|
||||
if (item.EqualIgnoreCase(cur)) continue;
|
||||
|
||||
Console.WriteLine("复制 {0} => {1}", item, cur);
|
||||
|
||||
try
|
||||
{
|
||||
item.AsDirectory().CopyToIfNewer(cur, "*.dll;*.exe;*.xml;*.pdb;*.cs;*.xs", false,
|
||||
name => Console.WriteLine("\t{1}\t{0}", name, item.CombinePath(name).AsFile().LastWriteTime.ToFullString()));
|
||||
}
|
||||
catch (Exception ex) { Console.WriteLine(" " + ex.Message); }
|
||||
}
|
||||
srcs = new String[] { @"..\..\WsLink.Biz\Bin", @"..\..\WsLink.Biz\DLL" };
|
||||
cur = ".".GetFullPath();
|
||||
foreach (var item in srcs)
|
||||
{
|
||||
// 跳过当前目录
|
||||
if (item.EqualIgnoreCase(cur)) continue;
|
||||
|
||||
Console.WriteLine("复制 {0} => {1}", item, cur);
|
||||
|
||||
try
|
||||
{
|
||||
item.AsDirectory().CopyToIfNewer(cur, "*.dll;*.exe;*.xml;*.pdb;*.cs;*.xs", false,
|
||||
name => Console.WriteLine("\t{1}\t{0}", name, item.CombinePath(name).AsFile().LastWriteTime.ToFullString()));
|
||||
}
|
||||
catch (Exception ex) { Console.WriteLine(" " + ex.Message); }
|
||||
}
|
|
@ -7,6 +7,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewLife.Redis", "NewLife.Re
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{582E00A2-4FA4-41DC-84AD-EE264A9FF4D8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewLife.Redis2", "NewLife.Redis2\NewLife.Redis2.csproj", "{CB63319A-9FEA-463A-8F61-A5485A5FB51B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Other", "Other", "{8CE754FB-5079-4ED7-93FF-B561CCE71DE6}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Readme.MD = Readme.MD
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -21,6 +28,10 @@ Global
|
|||
{582E00A2-4FA4-41DC-84AD-EE264A9FF4D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{582E00A2-4FA4-41DC-84AD-EE264A9FF4D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{582E00A2-4FA4-41DC-84AD-EE264A9FF4D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CB63319A-9FEA-463A-8F61-A5485A5FB51B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CB63319A-9FEA-463A-8F61-A5485A5FB51B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CB63319A-9FEA-463A-8F61-A5485A5FB51B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CB63319A-9FEA-463A-8F61-A5485A5FB51B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
<DocumentationFile>..\Bin\NewLife.Redis.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NewLife.Core">
|
||||
<HintPath>..\DLL\NewLife.Core.dll</HintPath>
|
||||
<Reference Include="NewLife.Core, Version=7.3.6815.39384, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NewLife.Core.7.3.6815.39384\lib\net45\NewLife.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -6,11 +6,11 @@ using System.Runtime.InteropServices;
|
|||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("新生命Redis缓存组件")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyDescription("Redis基础操作、列表结构、哈希结构,经过日均80亿次调用量的项目验证")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("NewLife.Redis")]
|
||||
[assembly: AssemblyCompany("新生命开发团队")]
|
||||
[assembly: AssemblyCopyright("©2002-2017 新生命开发团队 http://git.newlifex.com/NewLife/X")]
|
||||
[assembly: AssemblyCopyright("©2002-2018 新生命开发团队")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
@ -32,9 +32,11 @@ using System.Runtime.InteropServices;
|
|||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyFileVersion("1.0.2017.0820")]
|
||||
[assembly: AssemblyVersion("2.0.*")]
|
||||
[assembly: AssemblyFileVersion("2.0.2018.0829")]
|
||||
|
||||
/*
|
||||
* v2.0.2018.0829 全面扩充常用指令,日均80亿次调用量
|
||||
*
|
||||
* v1.0.2017.0820 建立Redis缓存组件
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NewLife.Caching
|
||||
{
|
||||
|
@ -43,7 +44,14 @@ namespace NewLife.Caching
|
|||
/// <summary>是否包含指定元素</summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public Boolean Contains(T item) => throw new NotSupportedException();
|
||||
public Boolean Contains(T item)
|
||||
{
|
||||
var count = Count;
|
||||
if (count > 1000) throw new NotSupportedException($"[{Key}]的元素个数过多,不支持!");
|
||||
|
||||
var list = GetAll();
|
||||
return list.Contains(item);
|
||||
}
|
||||
|
||||
/// <summary>复制到目标数组</summary>
|
||||
/// <param name="array"></param>
|
||||
|
@ -59,7 +67,14 @@ namespace NewLife.Caching
|
|||
/// <summary>查找指定元素位置</summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public Int32 IndexOf(T item) => throw new NotSupportedException();
|
||||
public Int32 IndexOf(T item)
|
||||
{
|
||||
var count = Count;
|
||||
if (count > 1000) throw new NotSupportedException($"[{Key}]的元素个数过多,不支持!");
|
||||
|
||||
var list = GetAll().ToList();
|
||||
return list.IndexOf(item);
|
||||
}
|
||||
|
||||
/// <summary>在指定位置插入</summary>
|
||||
/// <param name="index"></param>
|
||||
|
@ -83,8 +98,18 @@ namespace NewLife.Caching
|
|||
/// <returns></returns>
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
// 前面一段一次性取回来
|
||||
var size = 100;
|
||||
var arr = LRange(0, size - 1);
|
||||
foreach (var item in arr)
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
if (arr.Length < size) yield break;
|
||||
|
||||
// 后续逐个遍历
|
||||
var count = Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
for (var i = size; i < count; i++)
|
||||
{
|
||||
yield return this[i];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NewLife.Core" version="6.4.6412.39460" targetFramework="net461" />
|
||||
<package id="NewLife.Core" version="7.3.6815.39384" targetFramework="net45" />
|
||||
</packages>
|
|
@ -0,0 +1,41 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AssemblyName>NewLife.Redis</AssemblyName>
|
||||
<AssemblyTitle>新生命Redis缓存组件</AssemblyTitle>
|
||||
<Description>Redis基础操作、列表结构、哈希结构,经过日均80亿次调用量的项目验证</Description>
|
||||
<Company>新生命开发团队</Company>
|
||||
<Copyright>©2002-2018 新生命开发团队</Copyright>
|
||||
<FileVersion>2.0.2018.0829</FileVersion>
|
||||
<AssemblyVersion>2.0.*</AssemblyVersion>
|
||||
<Deterministic>false</Deterministic>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
<Version>2.0.2018.0829</Version>
|
||||
<RepositoryUrl>https://github.com/NewLifeX/NewLife.Redis</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<OutputPath>..\Bin</OutputPath>
|
||||
<DocumentationFile>..\Bin\netstandard2.0\NewLife.Redis.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<OutputPath>..\Bin</OutputPath>
|
||||
<DocumentationFile>..\Bin\netstandard2.0\NewLife.Redis.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NewLife.Redis\FullRedis.cs" Link="FullRedis.cs" />
|
||||
<Compile Include="..\NewLife.Redis\RedisBase.cs" Link="RedisBase.cs" />
|
||||
<Compile Include="..\NewLife.Redis\RedisHash.cs" Link="RedisHash.cs" />
|
||||
<Compile Include="..\NewLife.Redis\RedisList.cs" Link="RedisList.cs" />
|
||||
<Compile Include="..\NewLife.Redis\RedisQueue.cs" Link="RedisQueue.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="7.3.6815.39384" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,26 @@
|
|||
## 新生命Redis组件
|
||||
`NewLife.Redis` 是一个Redis客户端组件,以高性能处理大数据实时计算为目标。
|
||||
Redis协议基础实现Redis/RedisClient位于[X组件](https://github.com/NewLifeX/X),本库为扩展实现,主要增加列表结构、哈希结构、队列等高级功能。
|
||||
|
||||
源码: https://github.com/NewLifeX/NewLife.Redis
|
||||
Nuget:NewLife.Redis
|
||||
|
||||
---
|
||||
### 特性
|
||||
* 在ZTO大数据实时计算广泛应用,200多个Redis实例稳定工作一年多,每天处理近1亿包裹数据,日均调用量80亿次
|
||||
* 低延迟,Get/Set操作平均耗时200~600us(含往返网络通信)
|
||||
* 大吞吐,自带连接池,最大支持1000并发
|
||||
* 高性能,支持二进制序列化
|
||||
* 强大的视图引擎,支持子项目视图重写父项目相同位置视图,任意覆盖修改默认界面
|
||||
|
||||
---
|
||||
### Redis经验分享
|
||||
* 在Linux上多实例部署,实例个数等于处理器个数,各实例最大内存直接为本机物理内存,避免单个实例内存撑爆
|
||||
* 把海量数据(10亿+)根据key哈希(Crc16/Crc32)存放在多个实例上,读写性能成倍增长
|
||||
* 采用二进制序列化,而非常见Json序列化
|
||||
* 合理设计每一对Key的Value大小,包括但不限于使用批量获取,原则是让每次网络包控制在1.4k字节附近,减少通信次数
|
||||
* Redis客户端的Get/Set操作平均耗时200~600us(含往返网络通信),以此为参考评估网络环境和Redis客户端组件
|
||||
* 使用管道Pipeline合并一批命令
|
||||
* Redis的主要性能瓶颈是序列化、网络带宽和内存大小,滥用时处理器也会达到瓶颈
|
||||
* 其它可查优化技巧
|
||||
以上经验,源自于300多个实例4T以上空间一年多稳定工作的经验,并按照重要程度排了先后顺序,可根据场景需要酌情采用!
|
|
@ -31,9 +31,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NewLife.Core, Version=6.4.6441.4900, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DLL\NewLife.Core.dll</HintPath>
|
||||
<Reference Include="NewLife.Core, Version=7.3.6815.39384, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NewLife.Core.7.3.6815.39384\lib\net45\NewLife.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -50,6 +49,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NewLife.Redis\NewLife.Redis.csproj">
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NewLife.Core" version="7.3.6815.39384" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue