Commit b9ee9454 authored by Marc Gravell's avatar Marc Gravell

start xproj migration; implement raw Execute API

parent 993ed5eb
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BE213DFB-5334-4441-B975-0DBCFD5F5A73}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BasicTest</RootNamespace>
<Description>StackExchange.Redis.BasicTest .NET Core</Description>
<TargetFramework>netcoreapp1.0</TargetFramework>
<AssemblyName>BasicTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono|AnyCPU'">
<OutputPath>bin\Mono\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
<OutputType>Exe</OutputType>
<PackageId>BasicTest</PackageId>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis_Net45\StackExchange.Redis_Net45.csproj">
<Project>{7cec07f2-8c03-4c42-b048-738b215824c1}</Project>
<Name>StackExchange.Redis_Net45</Name>
</ProjectReference>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<DefineConstants>$(DefineConstants);CORE_CLR</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="System.Console" Version="4.0.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>939fa5f7-16aa-4847-812b-6ebc3748a86d</ProjectGuid>
<RootNamespace>BasicTest</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
\ No newline at end of file
......@@ -14,17 +14,39 @@ class Program
{
static void Main(string[] args)
{
int AsyncOpsQty = 500000;
if(args.Length == 1)
using (var conn = ConnectionMultiplexer.Connect("127.0.0.1:6379"))
{
int tmp;
if(int.TryParse(args[0], out tmp))
AsyncOpsQty = tmp;
var db = conn.GetDatabase();
// needs explicit RedisKey type for key-based
// sharding to work; will still work with strings,
// but no key-based sharding support
RedisKey key = "some_key";
// note: if command renames are configured in
// the API, they will still work automatically
db.Execute("del", key);
db.Execute("set", key, "12");
db.Execute("incrby", key, 4);
int i = (int)db.Execute("get", key);
Console.WriteLine(i); // 16;
}
MassiveBulkOpsAsync(AsyncOpsQty, true, true);
MassiveBulkOpsAsync(AsyncOpsQty, true, false);
MassiveBulkOpsAsync(AsyncOpsQty, false, true);
MassiveBulkOpsAsync(AsyncOpsQty, false, false);
//int AsyncOpsQty = 500000;
//if(args.Length == 1)
//{
// int tmp;
// if(int.TryParse(args[0], out tmp))
// AsyncOpsQty = tmp;
//}
//MassiveBulkOpsAsync(AsyncOpsQty, true, true);
//MassiveBulkOpsAsync(AsyncOpsQty, true, false);
//MassiveBulkOpsAsync(AsyncOpsQty, false, true);
//MassiveBulkOpsAsync(AsyncOpsQty, false, false);
}
static void MassiveBulkOpsAsync(int AsyncOpsQty, bool preserveOrder, bool withContinuation)
{
......
{
"version": "1.0.0-*",
"description": "StackExchange.Redis.BasicTest .NET Core",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"StackExchange.Redis": {
"version": "1.1.*",
"target": "project"
}
},
"runtimes": {
"win7-x64": {}
},
"frameworks": {
"netcoreapp1.0": {
"buildOptions": {
"define": [ "CORE_CLR" ]
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
},
"System.Console": "4.0.0"
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{97B45B3A-34DB-43C3-A979-37F217390142}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MigratedBookSleeveTestSuite</RootNamespace>
<Description>MigratedBookSleeveTestSuite</Description>
<TargetFrameworks>net45;netcoreapp1.0</TargetFrameworks>
<AssemblyName>MigratedBookSleeveTestSuite</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono|AnyCPU'">
<OutputPath>bin\Mono\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Batches.cs" />
<Compile Include="Config.cs" />
<Compile Include="Connection.cs" />
<Compile Include="Constraints.cs" />
<Compile Include="Hashes.cs" />
<Compile Include="Issues\Issue10.cs" />
<Compile Include="Issues\Massive Delete.cs" />
<Compile Include="Issues\SO10504853.cs" />
<Compile Include="Issues\SO10825542.cs" />
<Compile Include="Issues\SO11766033.cs" />
<Compile Include="Keys.cs" />
<Compile Include="Lists.cs" />
<Compile Include="Locking.cs" />
<Compile Include="Performance.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PubSub.cs" />
<Compile Include="redis-sharp.cs" />
<Compile Include="Scripting.cs" />
<Compile Include="Server.cs" />
<Compile Include="Sets.cs" />
<Compile Include="SortedSets.cs" />
<Compile Include="Strings.cs" />
<Compile Include="Transactions.cs" />
</ItemGroup>
<PackageId>MigratedBookSleeveTestSuite</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis_Net45\StackExchange.Redis_Net45.csproj">
<Project>{7cec07f2-8c03-4c42-b048-738b215824c1}</Project>
<Name>StackExchange.Redis_Net45</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" />
<PackageReference Include="nunit" Version="3.4.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<DefineConstants>$(DefineConstants);PLAT_SAFE_CONTINUATIONS;CORE_CLR</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="System.Console" Version="4.0.0" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.0.11" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.0.0" />
<PackageReference Include="System.Linq.Expressions" Version="4.1.0" />
<PackageReference Include="System.Reflection.Extensions" Version="4.0.1" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" />
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.0.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.0.1" />
<PackageReference Include="dotnet-test-nunit" Version="3.4.0-beta-1" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0fa2f7c5-1d36-40c4-82d1-93dbf43765d7</ProjectGuid>
<RootNamespace>MigratedBookSleeveTestSuite</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
\ No newline at end of file
{
"version": "1.0.0-*",
"description": "MigratedBookSleeveTestSuite",
"dependencies": {
"StackExchange.Redis": {
"version": "1.1.*",
"target": "project"
},
"nunit": "3.4.1"
},
"testRunner": "nunit",
"frameworks": {
"net45": {
},
"netcoreapp1.0": {
"imports": [
"portable-net45+win8"
],
"buildOptions": {
"define": [ "PLAT_SAFE_CONTINUATIONS", "CORE_CLR" ]
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
},
"System.Console": "4.0.0",
"System.Diagnostics.Debug": "4.0.11",
"System.Diagnostics.TraceSource": "4.0.0",
"System.Linq.Expressions": "4.1.0",
"System.Reflection.Extensions": "4.0.1",
"System.Runtime.InteropServices": "4.1.0",
"System.Threading.Tasks.Parallel": "4.0.1",
"Microsoft.CSharp": "4.0.1",
"dotnet-test-nunit": "3.4.0-beta-1"
}
}
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26403.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StackExchange.Redis", "StackExchange.Redis\StackExchange.Redis.xproj", "{EF84877F-59BE-41BE-9013-E765AF0BB72E}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StackExchange.Redis.StrongName", "StackExchange.Redis.StrongName\StackExchange.Redis.StrongName.xproj", "{46754D2A-AC16-4686-B113-3DB08ACF4269}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StackExchange.Redis.Tests", "StackExchange.Redis.Tests\StackExchange.Redis.Tests.xproj", "{3B8BD8F1-8BFC-4D8C-B4DA-25FFAF3D1DBE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3AD17044-6BFF-4750-9AC2-2CA466375F2A}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
......@@ -35,9 +28,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Redis Configs", "Redis Conf
Redis Configs\slave.conf = Redis Configs\slave.conf
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "BasicTest", "BasicTest\BasicTest.xproj", "{939FA5F7-16AA-4847-812B-6EBC3748A86D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Redis", "StackExchange.Redis\StackExchange.Redis.csproj", "{EF84877F-59BE-41BE-9013-E765AF0BB72E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Redis.StrongName", "StackExchange.Redis.StrongName\StackExchange.Redis.StrongName.csproj", "{46754D2A-AC16-4686-B113-3DB08ACF4269}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Redis.Tests", "StackExchange.Redis.Tests\StackExchange.Redis.Tests.csproj", "{3B8BD8F1-8BFC-4D8C-B4DA-25FFAF3D1DBE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicTest", "BasicTest\BasicTest.csproj", "{939FA5F7-16AA-4847-812B-6EBC3748A86D}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MigratedBookSleeveTestSuite", "MigratedBookSleeveTestSuite\MigratedBookSleeveTestSuite.xproj", "{0FA2F7C5-1D36-40C4-82D1-93DBF43765D7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigratedBookSleeveTestSuite", "MigratedBookSleeveTestSuite\MigratedBookSleeveTestSuite.csproj", "{0FA2F7C5-1D36-40C4-82D1-93DBF43765D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docs", "Docs\Docs.csproj", "{7909952C-0F38-4E62-A7BA-1A77E1452FDA}"
EndProject
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>High performance Redis client, incorporating both synchronous and asynchronous usage.</Description>
<Copyright>Stack Exchange inc. 2014-</Copyright>
<AssemblyTitle>StackExchange.Redis.StrongName</AssemblyTitle>
<VersionPrefix>1.2.0</VersionPrefix>
<Authors>Stack Exchange inc., marc.gravell</Authors>
<TargetFrameworks>net40;net45;net46;netstandard1.5</TargetFrameworks>
<DefineConstants>$(DefineConstants);STRONG_NAME</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>StackExchange.Redis.StrongName</AssemblyName>
<AssemblyOriginatorKeyFile>../StackExchange.Redis.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>StackExchange.Redis.StrongName</PackageId>
<PackageTags>Async;Redis;Cache;PubSub;Messaging</PackageTags>
<PackageProjectUrl>https://github.com/StackExchange/StackExchange.Redis</PackageProjectUrl>
<PackageLicenseUrl>https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/StackExchange/StackExchange.Redis</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<Compile Remove="..\StackExchange.Redis\obj\**\*;..\StackExchange.Redis\Properties\AssemblyInfo.cs" />
<Compile Include="..\StackExchange.Redis\**\*.cs" Exclude="..\StackExchange.Redis\obj\**\*;bin\**;obj\**;**\*.xproj;packages\**;..\StackExchange.Redis\Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<PackageReference Include="Microsoft.Bcl" Version="1.1.10" />
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_SOCKET_MODE_POLL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<DefineConstants>$(DefineConstants);CORE_CLR</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<PackageReference Include="System.Collections" Version="4.0.11" />
<PackageReference Include="System.Collections.Concurrent" Version="4.0.12" />
<PackageReference Include="System.Collections.NonGeneric" Version="4.0.1" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.0.1" />
<PackageReference Include="System.IO.Compression" Version="4.1.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.0.1" />
<PackageReference Include="System.Linq" Version="4.1.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.0.0" />
<PackageReference Include="System.Net.Security" Version="4.0.0" />
<PackageReference Include="System.Net.Sockets" Version="4.1.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.0.1" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.0.1" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.1.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.1.0" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.0.0" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.2.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.1.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.1.0" />
<PackageReference Include="System.Threading" Version="4.0.11" />
<PackageReference Include="System.Threading.Thread" Version="4.0.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.0.10" />
<PackageReference Include="System.Threading.Timer" Version="4.0.1" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>46754d2a-ac16-4686-b113-3db08acf4269</ProjectGuid>
<RootNamespace>StackExchange.Redis.StrongName</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
\ No newline at end of file
{
"packOptions": {
"summary": "Redis client library",
"tags": [ "Async", "Redis", "Cache", "PubSub", "Messaging" ],
"owners": [ "marc.gravell" ],
"requireLicenseAcceptance": false,
"projectUrl": "https://github.com/StackExchange/StackExchange.Redis",
"licenseUrl": "https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE",
"repository": {
"type": "git",
"url": "https://github.com/StackExchange/StackExchange.Redis"
}
},
"title": "StackExchange.Redis.StrongName",
"version": "1.2.0",
"description": "High performance Redis client, incorporating both synchronous and asynchronous usage.",
"authors": [ "Stack Exchange inc., marc.gravell" ],
"copyright": "Stack Exchange inc. 2014-",
"dependencies": {
},
"buildOptions": {
"allowUnsafe": true,
"xmlDoc": true,
"keyFile": "../StackExchange.Redis.snk",
"define": [ "STRONG_NAME" ],
"compile": {
"include": [
"../StackExchange.Redis/**/*.cs"
],
"exclude": [
"../StackExchange.Redis/obj/"
],
"excludeFiles": [
"../StackExchange.Redis/Properties/AssemblyInfo.cs"
]
}
},
"frameworks": {
"net40": {
"dependencies": {
"Microsoft.Bcl": "1.1.10",
"Microsoft.Bcl.Async": "1.0.168"
},
"buildOptions": {
"define": [ "FEATURE_SERIALIZATION", "FEATURE_SOCKET_MODE_POLL" ]
}
},
"net45": {
"frameworkAssemblies": {
"System.IO.Compression": "4.0.0.0"
},
"buildOptions": {
"define": [ "FEATURE_SERIALIZATION", "FEATURE_SOCKET_MODE_POLL" ]
}
},
"net46": {
"frameworkAssemblies": {
"System.IO.Compression": "4.0.0.0"
},
"buildOptions": {
"define": [ "FEATURE_SERIALIZATION", "FEATURE_SOCKET_MODE_POLL" ]
}
},
"netstandard1.5": {
"buildOptions": {
"define": [ "CORE_CLR" ]
},
"dependencies": {
"System.Collections": "4.0.11",
"System.Collections.Concurrent": "4.0.12",
"System.Collections.NonGeneric": "4.0.1",
"System.Diagnostics.Tools": "4.0.1",
"System.IO.Compression": "4.1.0",
"System.IO.FileSystem": "4.0.1",
"System.Linq": "4.1.0",
"System.Net.NameResolution": "4.0.0",
"System.Net.Security": "4.0.0",
"System.Net.Sockets": "4.1.0",
"System.Reflection.Emit": "4.0.1",
"System.Reflection.Emit.Lightweight": "4.0.1",
"System.Reflection.TypeExtensions": "4.1.0",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
"System.Security.Cryptography.Algorithms": "4.2.0",
"System.Security.Cryptography.X509Certificates": "4.1.0",
"System.Text.RegularExpressions": "4.1.0",
"System.Threading": "4.0.11",
"System.Threading.Thread": "4.0.0",
"System.Threading.ThreadPool": "4.0.10",
"System.Threading.Timer": "4.0.1"
}
}
}
}
\ No newline at end of file
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public class AdhocTests : TestBase
{
[Test]
public void TestAdhocCommandsAPI()
{
using (var conn = Create())
{
var db = conn.GetDatabase();
// needs explicit RedisKey type for key-based
// sharding to work; will still work with strings,
// but no key-based sharding support
RedisKey key = "some_key";
// note: if command renames are configured in
// the API, they will still work automatically
db.Execute("del", key);
db.Execute("set", key, "12");
db.Execute("incrby", key, 4);
int i = (int) db.Execute("get", key);
Assert.AreEqual(16, i);
}
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>StackExchange.Redis.Tests</Description>
<TargetFramework>netcoreapp1.0</TargetFramework>
<AssemblyName>StackExchange.Redis.Tests</AssemblyName>
<PackageId>StackExchange.Redis.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" />
<PackageReference Include="redis-64" Version="3.0.503" />
<PackageReference Include="nunit" Version="3.4.1" />
<PackageReference Include="dotnet-test-nunit" Version="3.4.0-beta-1" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<DefineConstants>$(DefineConstants);CORE_CLR</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="System.Console" Version="4.0.0" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.0.11" />
<PackageReference Include="System.Linq.Expressions" Version="4.1.0" />
<PackageReference Include="System.Reflection.Extensions" Version="4.0.1" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" />
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.0.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.0.1" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>3b8bd8f1-8bfc-4d8c-b4da-25ffaf3d1dbe</ProjectGuid>
<RootNamespace>StackExchange.Redis.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
\ No newline at end of file
{
"version": "1.0.0-*",
"description": "StackExchange.Redis.Tests",
"dependencies": {
"StackExchange.Redis": {
"version": "1.1.*",
"target": "project"
},
"redis-64": "3.0.503",
"nunit": "3.4.1",
"dotnet-test-nunit": "3.4.0-beta-1"
},
"testRunner": "nunit",
"frameworks": {
"netcoreapp1.0": {
"imports": [
"portable-net45+win8"
],
"buildOptions": {
"define": [ "CORE_CLR" ]
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
},
"System.Console": "4.0.0",
"System.Diagnostics.Debug": "4.0.11",
"System.Linq.Expressions": "4.1.0",
"System.Reflection.Extensions": "4.0.1",
"System.Runtime.InteropServices": "4.1.0",
"System.Threading.Tasks.Parallel": "4.0.1",
"Microsoft.CSharp": "4.0.1"
}
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>High performance Redis client, incorporating both synchronous and asynchronous usage.</Description>
<Copyright>Stack Exchange inc. 2014-</Copyright>
<AssemblyTitle>StackExchange.Redis</AssemblyTitle>
<VersionPrefix>1.2.0</VersionPrefix>
<Authors>Stack Exchange inc., marc.gravell</Authors>
<TargetFrameworks>net45;net46;netstandard1.5</TargetFrameworks><!--net40;-->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>StackExchange.Redis</AssemblyName>
<PackageId>StackExchange.Redis</PackageId>
<PackageTags>Async;Redis;Cache;PubSub;Messaging</PackageTags>
<PackageProjectUrl>https://github.com/StackExchange/StackExchange.Redis</PackageProjectUrl>
<PackageLicenseUrl>https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/StackExchange/StackExchange.Redis</RepositoryUrl>
<CoreFxVersion>4.3.0</CoreFxVersion>
<ApplicationIcon />
<OutputTypeEx>library</OutputTypeEx>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<PackageReference Include="Microsoft.Bcl" Version="1.1.10" />
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System.IO.Compression" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_SOCKET_MODE_POLL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<DefineConstants>$(DefineConstants);CORE_CLR</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<PackageReference Include="System.Collections" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Collections.Concurrent" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Collections.NonGeneric" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Diagnostics.Tools" Version="$(CoreFxVersion)" />
<PackageReference Include="System.IO.Compression" Version="$(CoreFxVersion)" />
<PackageReference Include="System.IO.FileSystem" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Linq" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Net.NameResolution" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Net.Security" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Net.Sockets" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Reflection.Emit" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Runtime.Extensions" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Text.RegularExpressions" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Threading" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Threading.Thread" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Threading.ThreadPool" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Threading.Timer" Version="$(CoreFxVersion)" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>ef84877f-59be-41be-9013-e765af0bb72e</ProjectGuid>
<RootNamespace>StackExchange.Redis</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
\ No newline at end of file
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
......@@ -172,6 +173,29 @@ internal byte[] GetBytes(RedisCommand command)
{
return map[(int)command];
}
internal byte[] GetBytes(string command)
{
if (command == null) return null;
if(Enum.TryParse(command, true, out RedisCommand cmd))
{ // we know that one!
return map[(int)cmd];
}
var bytes = (byte[])_unknownCommands[command];
if(bytes == null)
{
lock(_unknownCommands)
{ // double-checked
bytes = (byte[])_unknownCommands[command];
if(bytes == null)
{
bytes = Encoding.ASCII.GetBytes(command);
_unknownCommands[command] = bytes;
}
}
}
return bytes;
}
static readonly Hashtable _unknownCommands = new Hashtable();
internal bool IsAvailable(RedisCommand command)
{
......
......@@ -24,6 +24,13 @@ internal static Exception AdminModeNotEnabled(bool includeDetail, RedisCommand c
return ex;
}
internal static Exception CommandDisabled(bool includeDetail, RedisCommand command, Message message, ServerEndPoint server)
{
string s = GetLabel(includeDetail, command, message);
var ex = new RedisCommandException("This operation has been disabled in the command-map and cannot be used: " + s);
if (includeDetail) AddDetail(ex, message, server, s);
return ex;
}
internal static Exception CommandDisabled(bool includeDetail, string command, Message message, ServerEndPoint server)
{
string s = GetLabel(includeDetail, command, message);
var ex = new RedisCommandException("This operation has been disabled in the command-map and cannot be used: " + s);
......@@ -197,6 +204,10 @@ private static void AddDetail(Exception exception, Message message, ServerEndPoi
static string GetLabel(bool includeDetail, RedisCommand command, Message message)
{
return message == null ? command.ToString() : (includeDetail ? message.CommandAndKey : message.Command.ToString());
}
static string GetLabel(bool includeDetail, string command, Message message)
{
return message == null ? command : (includeDetail ? message.CommandAndKey : message.Command.ToString());
}
internal static Exception UnableToConnect(bool abortOnConnect, string failureMessage=null)
......
......@@ -532,7 +532,24 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// <returns>the number of clients that received the message.</returns>
/// <remarks>http://redis.io/commands/publish</remarks>
long Publish(RedisChannel channel, RedisValue message, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Execute an arbitrary command against the server; this is primarily intended for
/// executing modules, but may also be used to provide access to new features that lack
/// a direct API
/// </summary>
/// <returns>A dynamic representation of the command's result</returns>
RedisResult Execute(string command, params object[] args);
/// <summary>
/// Execute an arbitrary command against the server; this is primarily intended for
/// executing modules, but may also be used to provide access to new features that lack
/// a direct API
/// </summary>
/// <returns>A dynamic representation of the command's result</returns>
RedisResult Execute(string command, object[] args, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Execute a Lua script against the server
/// </summary>
......
......@@ -513,6 +513,23 @@ public interface IDatabaseAsync : IRedisAsync
/// <returns>A dynamic representation of the script's result</returns>
Task<RedisResult> ScriptEvaluateAsync(string script, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Execute an arbitrary command against the server; this is primarily intended for
/// executing modules, but may also be used to provide access to new features that lack
/// a direct API
/// </summary>
/// <returns>A dynamic representation of the command's result</returns>
Task<RedisResult> ExecuteAsync(string command, params object[] args);
/// <summary>
/// Execute an arbitrary command against the server; this is primarily intended for
/// executing modules, but may also be used to provide access to new features that lack
/// a direct API
/// </summary>
/// <returns>A dynamic representation of the command's result</returns>
Task<RedisResult> ExecuteAsync(string command, object[] args, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Execute a Lua script against the server using just the SHA1 hash
/// </summary>
......
......@@ -360,6 +360,13 @@ public long Publish(RedisChannel channel, RedisValue message, CommandFlags flags
return Inner.Publish(ToInner(channel), message, flags);
}
public RedisResult Execute(string command, params object[] args)
=> Execute(command, args, CommandFlags.None);
public RedisResult Execute(string command, object[] args, CommandFlags flags = CommandFlags.None)
{
return Inner.Execute(command, ToInner(args), flags);
}
public RedisResult ScriptEvaluate(byte[] hash, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None)
{
// TODO: The return value could contain prefixed keys. It might make sense to 'unprefix' those?
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
......@@ -343,7 +344,12 @@ public Task<long> PublishAsync(RedisChannel channel, RedisValue message, Command
{
return Inner.PublishAsync(ToInner(channel), message, flags);
}
public Task<RedisResult> ExecuteAsync(string command, params object[] args)
=> ExecuteAsync(command, args, CommandFlags.None);
public Task<RedisResult> ExecuteAsync(string command, object[] args, CommandFlags flags = CommandFlags.None)
{
return Inner.ExecuteAsync(command, ToInner(args), flags);
}
public Task<RedisResult> ScriptEvaluateAsync(byte[] hash, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None)
{
// TODO: The return value could contain prefixed keys. It might make sense to 'unprefix' those?
......@@ -707,7 +713,28 @@ protected RedisKey ToInnerOrDefault(RedisKey outer)
return ToInner(outer);
}
}
protected object[] ToInner(object[] args)
{
if (args != null && args.Any(x => x is RedisKey || x is RedisChannel))
{
var withPrefix = new object[args.Length];
for (int i = 0; i < args.Length; i++)
{
var arg = args[i];
if (arg is RedisKey)
{
arg = ToInner((RedisKey)arg);
}
else if (arg is RedisChannel)
{
arg = ToInner((RedisChannel)arg);
}
withPrefix[i] = arg;
}
args = withPrefix;
}
return args;
}
protected RedisKey[] ToInner(RedisKey[] outer)
{
if (outer == null || outer.Length == 0)
......
......@@ -812,6 +812,7 @@ private bool WriteMessageToServer(PhysicalConnection connection, Message message
connection.SetUnknownDatabase();
}
break;
case RedisCommand.UNKNOWN:
case RedisCommand.DISCARD:
case RedisCommand.EXEC:
connection.SetUnknownDatabase();
......
......@@ -474,6 +474,21 @@ internal void WriteHeader(RedisCommand command, int arguments)
WriteRaw(outStream, arguments + 1);
WriteUnified(outStream, commandBytes);
}
internal void WriteHeader(string command, int arguments)
{
var commandBytes = Multiplexer.CommandMap.GetBytes(command);
if (commandBytes == null)
{
throw ExceptionFactory.CommandDisabled(Multiplexer.IncludeDetailInExceptions, command, null, Bridge.ServerEndPoint);
}
outStream.WriteByte((byte)'*');
// remember the time of the first write that still not followed by read
Interlocked.CompareExchange(ref firstUnansweredWriteTickCount, Environment.TickCount, 0);
WriteRaw(outStream, arguments + 1);
WriteUnified(outStream, commandBytes);
}
static void WriteRaw(Stream stream, long value, bool withLengthPrefix = false)
{
......
......@@ -183,5 +183,7 @@ enum RedisCommand
ZSCAN,
ZSCORE,
ZUNIONSTORE,
UNKNOWN,
}
}
......@@ -1059,6 +1059,20 @@ public RedisResult ScriptEvaluate(string script, RedisKey[] keys = null, RedisVa
throw;
}
}
public RedisResult Execute(string command, params object[] args)
=> Execute(command, args, CommandFlags.None);
public RedisResult Execute(string command, object[] args, CommandFlags flags = CommandFlags.None)
{
var msg = new ExecuteMessage(Database, flags, command, args);
return ExecuteSync(msg, ResultProcessor.ScriptResult);
}
public Task<RedisResult> ExecuteAsync(string command, params object[] args)
=> ExecuteAsync(command, args, CommandFlags.None);
public Task<RedisResult> ExecuteAsync(string command, object[] args, CommandFlags flags = CommandFlags.None)
{
var msg = new ExecuteMessage(Database, flags, command, args);
return ExecuteAsync(msg, ResultProcessor.ScriptResult);
}
public RedisResult ScriptEvaluate(byte[] hash, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None)
{
var msg = new ScriptEvalMessage(Database, flags, hash, keys, values);
......@@ -2429,6 +2443,52 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
return false;
}
}
private sealed class ExecuteMessage : Message
{
private readonly string _command;
private static readonly object[] NoArgs = new object[0];
private readonly object[] args;
public ExecuteMessage(int db, CommandFlags flags, string command, object[] args) : base(db, flags, RedisCommand.UNKNOWN)
{
_command = command;
this.args = args ?? NoArgs;
}
internal override void WriteImpl(PhysicalConnection physical)
{
physical.WriteHeader(_command, args.Length);
for(int i = 0; i < args.Length; i++)
{
object arg = args[i];
if (arg is RedisKey)
{
physical.Write((RedisKey)arg);
}
else if (arg is RedisChannel)
{
physical.Write((RedisChannel)arg);
}
else
{ // recognises well-known types
physical.Write(RedisValue.Parse(arg));
}
}
}
public override string CommandAndKey => _command;
public override int GetHashSlot(ServerSelectionStrategy serverSelectionStrategy)
{
int slot = ServerSelectionStrategy.NoSlot;
for (int i = 0 ; i < args.Length ; i++)
{
object arg = args[i];
if(arg is RedisKey)
{
slot = serverSelectionStrategy.CombineSlot(slot, (RedisKey)arg);
}
}
return slot;
}
}
private sealed class ScriptEvalMessage : Message, IMultiMessage
{
private readonly RedisKey[] keys;
......
......@@ -90,6 +90,7 @@ internal override Task<T> ExecuteAsync<T>(Message message, ResultProcessor<T> pr
switch(message.Command)
{
case RedisCommand.UNKNOWN:
case RedisCommand.EVAL:
case RedisCommand.EVALSHA:
// people can do very naughty things in an EVAL
......
......@@ -393,6 +393,21 @@ int IComparable.CompareTo(object obj)
else blob = value;
return new RedisValue(0, blob);
}
internal static RedisValue Parse(object obj)
{
if (obj == null) return RedisValue.Null;
if (obj is RedisValue) return (RedisValue)obj;
if (obj is string) return (RedisValue)(string)obj;
if (obj is int) return (RedisValue)(int)obj;
if (obj is double) return (RedisValue)(double)obj;
if (obj is byte[]) return (RedisValue)(byte[])obj;
if (obj is bool) return (RedisValue)(bool)obj;
if (obj is long) return (RedisValue)(long)obj;
if (obj is float) return (RedisValue)(float)obj;
throw new InvalidOperationException("Unable to format type for redis: " + obj.GetType().FullName);
}
/// <summary>
/// Creates a new RedisValue from a Boolean
/// </summary>
......
{
"packOptions": {
"summary": "Redis client library",
"tags": [ "Async", "Redis", "Cache", "PubSub", "Messaging" ],
"owners": [ "marc.gravell" ],
"requireLicenseAcceptance": false,
"projectUrl": "https://github.com/StackExchange/StackExchange.Redis",
"licenseUrl": "https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE",
"repository": {
"type": "git",
"url": "https://github.com/StackExchange/StackExchange.Redis"
}
},
"title": "StackExchange.Redis",
"version": "1.2.0",
"description": "High performance Redis client, incorporating both synchronous and asynchronous usage.",
"authors": [ "Stack Exchange inc., marc.gravell" ],
"copyright": "Stack Exchange inc. 2014-",
"dependencies": {
},
"buildOptions": {
"allowUnsafe": true,
"xmlDoc": true,
"compile": {
"excludeFiles": [
"Properties/AssemblyInfo.cs"
]
}
},
"frameworks": {
"net40": {
"dependencies": {
"Microsoft.Bcl": "1.1.10",
"Microsoft.Bcl.Async": "1.0.168"
},
"buildOptions": {
"define": [ "FEATURE_SERIALIZATION", "FEATURE_SOCKET_MODE_POLL" ]
}
},
"net45": {
"frameworkAssemblies": {
"System.IO.Compression": "4.0.0.0"
},
"buildOptions": {
"define": [ "FEATURE_SERIALIZATION", "FEATURE_SOCKET_MODE_POLL" ]
}
},
"net46": {
"frameworkAssemblies": {
"System.IO.Compression": "4.0.0.0"
},
"buildOptions": {
"define": [ "FEATURE_SERIALIZATION", "FEATURE_SOCKET_MODE_POLL" ]
}
},
"netstandard1.5": {
"buildOptions": {
"define": [ "CORE_CLR" ]
},
"dependencies": {
"System.Collections": "4.0.11",
"System.Collections.Concurrent": "4.0.12",
"System.Collections.NonGeneric": "4.0.1",
"System.Diagnostics.Tools": "4.0.1",
"System.IO.Compression": "4.1.0",
"System.IO.FileSystem": "4.0.1",
"System.Linq": "4.1.0",
"System.Net.NameResolution": "4.0.0",
"System.Net.Security": "4.0.0",
"System.Net.Sockets": "4.1.0",
"System.Reflection.Emit": "4.0.1",
"System.Reflection.Emit.Lightweight": "4.0.1",
"System.Reflection.TypeExtensions": "4.1.0",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0",
"System.Security.Cryptography.Algorithms": "4.2.0",
"System.Security.Cryptography.X509Certificates": "4.1.0",
"System.Text.RegularExpressions": "4.1.0",
"System.Threading": "4.0.11",
"System.Threading.Thread": "4.0.0",
"System.Threading.ThreadPool": "4.0.10",
"System.Threading.Timer": "4.0.1"
}
}
}
}
\ No newline at end of file
{
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment