RedisNet 1.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RedisNet --version 1.1.0
NuGet\Install-Package RedisNet -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RedisNet" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RedisNet --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RedisNet, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RedisNet as a Cake Addin #addin nuget:?package=RedisNet&version=1.1.0 // Install RedisNet as a Cake Tool #tool nuget:?package=RedisNet&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Local Test
New Features
- Compression
- Key deletion with regex
Compression Benchmark Results
BenchmarkDotNet=v0.12.1, OS=macOS 11.3 (20E232) [Darwin 20.4.0]
Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=5.0.201
[Host] : .NET Core 3.1.13 (CoreCLR 4.700.21.11102, CoreFX 4.700.21.11602), X64 RyuJIT DEBUG
Local Redis
Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|
WithCompressionBenchmark | 36.86 ms | 0.654 ms | 0.612 ms | 1142.8571 | 1000.0000 | 928.5714 | 4.83 MB |
WithoutCompressionBenchmark | 24.96 ms | 0.490 ms | 0.545 ms | 375.0000 | 218.7500 | 218.7500 | 2.25 MB |
Remote Redis
Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|
WithCompressionBenchmark | 668.2 ms | 13.34 ms | 27.24 ms | - | - | - | 4.88 MB |
WithoutCompressionBenchmark | 1,387.1 ms | 26.92 ms | 37.74 ms | - | - | - | 2.39 MB |
Usage Method 1
Single redis server
Prerequisite
docker run --name redis1 -d -p 6379:6379 redis redis-server --appendonly yes
public void ConfigureServices(IServiceCollection services)
{
var redis2ConfigurationOptions = ConfigurationOptions.Parse("localhost:6379");
redis2ConfigurationOptions.ReconnectRetryPolicy = new ExponentialRetry(1000);
services.AddRedisDotNet(new RedisCacheOptions()
{
ConfigurationOptions = redis2ConfigurationOptions
});
}
public class TestController : Controller
{
private readonly IRedisService _redisService;
public TestController(IRedisService redisService){
_redisService = redisService;
}
public IActionResult Get(string key){
var result = _redisService.GetString(key);
return OK(result);
}
public async Task<IActionResult> GetAsync(string key){
var result = await _redisService.GetStringAsync(key);
return OK(result);
}
}
Usage Method 2
Multiple Redis servers
Prerequisite
docker run --name redis1 -d -p 6379:6379 redis redis-server --appendonly yes
docker run --name redis2 -d -p 6380:6380 redis redis-server --appendonly yes
public void ConfigureServices(IServiceCollection services)
{
var redis1ConfigurationOptions = ConfigurationOptions.Parse("localhost:6379");
redis1ConfigurationOptions.ReconnectRetryPolicy = new ExponentialRetry(1000);
services.AddRedisDotNet<Redis1>(new RedisCacheOptions()
{
ConfigurationOptions = redis1ConfigurationOptions
});
var redis2ConfigurationOptions = ConfigurationOptions.Parse("localhost:6380");
redis2ConfigurationOptions.ReconnectRetryPolicy = new ExponentialRetry(1000);
services.AddRedisDotNet<Redis2>(new RedisCacheOptions()
{
ConfigurationOptions = redis2ConfigurationOptions
});
}
public class Redis1 : RedisService<Redis1>
{
public Redis1(IOptionsMonitor<RedisCacheOptions> cacheOptions) : base(cacheOptions)
{
}
}
public class Redis2 : RedisService<Redis2>
{
public Redis2(IOptionsMonitor<RedisCacheOptions> cacheOptions) : base(cacheOptions)
{
}
}
public class Redis1Controller : ControllerBase
{
private readonly Redis1 _redis1;
public Redis1Controller(Redis1 redis1)
{
_redis1 = redis1;
}
[HttpGet]
public async Task<IActionResult> Get()
{
return Ok(await _redis1.GetStringAsync("redis1"));
}
}
public class Redis2Controller : ControllerBase
{
private readonly Redis2 _redis2;
public Redis2Controller(Redis2 redis2)
{
_redis2 = redis2;
}
[HttpGet]
public async Task<IActionResult> Get()
{
return Ok(await _redis2.GetStringAsync("redis2"));
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 3.1.8)
- Newtonsoft.Json (>= 12.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.