IT.Redis.Entity
2.1.2
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.1
This package targets .NET Framework 4.6.1. The package is compatible with this framework or higher.
dotnet add package IT.Redis.Entity --version 2.1.2
NuGet\Install-Package IT.Redis.Entity -Version 2.1.2
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="IT.Redis.Entity" Version="2.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IT.Redis.Entity --version 2.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IT.Redis.Entity, 2.1.2"
#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 IT.Redis.Entity as a Cake Addin #addin nuget:?package=IT.Redis.Entity&version=2.1.2 // Install IT.Redis.Entity as a Cake Tool #tool nuget:?package=IT.Redis.Entity&version=2.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
IT.Redis.Entity
Object mapping for Redis
Declaring an entity class with mutable keys
class Document
{
private Guid _guid;
private int _index;
// Add readonly modifier
#pragma warning disable IDE0044
#pragma warning disable CS0649
private byte[]? _redisKey;
#pragma warning restore CS0649
#pragma warning restore IDE0044
private byte _redisKeyBits;
public byte[]? RedisKey => _redisKey;
public byte RedisKeyBits => _redisKeyBits;
public Guid Guid
{
get => _guid;
set
{
if (_guid != value)
{
_guid = value;
_redisKeyBits |= 1;
}
}
}
public int Index
{
get => _index;
set
{
if (_index != value)
{
_index = value;
_redisKeyBits |= 2;
}
}
}
public string? Name { get; set; }
}
Init RedisValue formatter
#if NETCOREAPP3_1_OR_GREATER
var formatter = IT.Redis.Entity.Formatters.JsonFormatter.Default;
#endif
Configuration
var configBuilder = new RedisEntityConfigurationBuilder(formatter);
configBuilder
.Entity<Document>()
.HasKeyPrefix("app:docs")
.HasKey(x => x.Guid)
.HasKey(x => x.Index);
var config = configBuilder.Build();
var reDoc = config.NewEntity<Document>();
Connect to the database redis
var connection = ConnectionMultiplexer.Connect(connectionString);
var db = connection.GetDatabase()!;
New Document and save to redis
var guid = Guid.NewGuid();
var doc = new Document
{
Guid = guid,
Index = 1,
Name = "doc1"
};
db.EntitySet(doc, reDoc);
doc.Index = 2;
doc.Name = "doc2";
db.EntitySet(doc, reDoc);
Load into existing Document
doc.Index = 3;
Assert.That(db.EntityLoad(doc, reDoc), Is.False);
Assert.That(doc.Name, Is.EqualTo("doc2"));
doc.Index = 1;
Assert.That(db.EntityLoad(doc, reDoc), Is.True);
Assert.That(doc.Name, Is.EqualTo("doc1"));
Build redisKey from EntityKeyBuilder
var redisKey = reDoc.KeyBuilder.BuildKey(guid, 1);
Assert.That(redisKey, Is.EqualTo(doc.RedisKey));
Build redisKey from KeyBuilder
var redisKey2 = KeyBuilder.Default.BuildKey("app:docs", guid, 1);
Assert.That(redisKey2, Is.EqualTo(redisKey));
Get Document by redis key
var doc1 = db.EntityGet(redisKey, reDoc);
Assert.That(doc1, Is.Not.Null);
Assert.That(doc1.Name, Is.EqualTo("doc1"));
var redisKey3 = reDoc.KeyBuilder.BuildKey(guid, 3);
var doc3 = db.EntityGet(redisKey3, reDoc);
Assert.That(doc3, Is.Null);
Set global factories
RedisEntity<Document>.Factory = () => reDoc;
RedisEntity.Config = config;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 is compatible. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.1
- StackExchange.Redis (>= 2.6.122)
-
.NETFramework 4.7.2
- StackExchange.Redis (>= 2.6.122)
-
.NETStandard 2.0
- StackExchange.Redis (>= 2.6.122)
-
.NETStandard 2.1
- StackExchange.Redis (>= 2.6.122)
-
net6.0
- StackExchange.Redis (>= 2.6.122)
-
net7.0
- StackExchange.Redis (>= 2.6.122)
-
net8.0
- StackExchange.Redis (>= 2.6.122)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.2 | 114 | 5/22/2024 |
2.1.1 | 100 | 5/22/2024 |
2.1.1-pre1 | 94 | 5/18/2024 |
2.1.0 | 97 | 5/16/2024 |
2.1.0-pre1 | 95 | 5/10/2024 |
2.0.1 | 267 | 12/19/2023 |
2.0.1-pre1 | 125 | 12/19/2023 |
2.0.0 | 213 | 10/30/2023 |
2.0.0-pre6 | 128 | 10/27/2023 |
2.0.0-pre5 | 99 | 10/17/2023 |
2.0.0-pre4 | 136 | 9/26/2023 |
2.0.0-pre3 | 104 | 9/25/2023 |