StackExchange.Redis.DataTypesCore 0.0.3

dotnet add package StackExchange.Redis.DataTypesCore --version 0.0.3
                    
NuGet\Install-Package StackExchange.Redis.DataTypesCore -Version 0.0.3
                    
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="StackExchange.Redis.DataTypesCore" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StackExchange.Redis.DataTypesCore" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="StackExchange.Redis.DataTypesCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StackExchange.Redis.DataTypesCore --version 0.0.3
                    
#r "nuget: StackExchange.Redis.DataTypesCore, 0.0.3"
                    
#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.
#:package StackExchange.Redis.DataTypesCore@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StackExchange.Redis.DataTypesCore&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=StackExchange.Redis.DataTypesCore&version=0.0.3
                    
Install as a Cake Tool

---

.NET CORE VERSION OF THIS REPOSITORY : https://github.com/ArinGhazarian/StackExchange.Redis.DataTypes

---

StackExchange.Redis.DataTypes

Implementation of common .NET collection types (i.e IDictionary, ISet, IList) via abstraction over StackExchange.Redis. By using this library you will be able to seamlessly replace your common in-memory collection types with types stored in redis db. All you need to do is to instantiate a redis collection type and continue coding as if you are working with common in-memory collections.

Installation

You can install this library either from NuGet UI StackExchange.Redis.DataTypes, or from the package manager console:

PM> Install-Package StackExchange.Redis.DataTypes

How to get started?

This library uses StackExchange.Redis to communicate with redis db and serialize/deserialize the data using Json.NET library. You don't need to worry about serialization/deserialization of your data because it works under the hood but you need to be familiar with StackExchange.Redis. Well at least you need to know how to configure and instantiate ConnectionMultiplexer. After you learned the Basic usage of StackExchange.Redis you can start using this library.

Some code samples

  • Create a ConnectionMultiplexer. Creating ConnectionMultiplexer object is costly so it is recommended to store and reuse it.
var connectionMultiplexer = ConnectionMultiplexer.Connect("localhost,abortConnect=false"); // replace localhost with your redis db address
  • You can either create a RedisType by using RedisTypeFactory or by instantiating the desired type directly. You should specify your type name so it will be stored in redis db under that name and can be accessed later.
var redisTypeFactory = new RedisTypeFactory(connectionMultiplexer);

// Create a redis dictionary under the name of "Person". (Person is a sample class with three fields (ID, Name, Age))
var redisDictionary = redisTypeFactory.GetDictionary<int, Person>("Person");
  • Adding items to dictionary and iterate through it
redisDictionary.Add(1, new Person { ID = 1, Name = "Steve", Age = 20 });
redisDictionary.Add(2, new Person { ID = 2, Name = "Mike", Age = 25 });
redisDictionary.Add(3, new Person { ID = 3, Name = "Lara", Age = 30 });

foreach (var person in redisDictionary)
{
	Console.WriteLine("ID: {0}, Name: {1}, Age: {2}", person.Value.ID, person.Value.Name, person.Value.Age);
}
  • Find a specific person
var lara = redisDictionary.First(kvp => kvp.Value.Name == "Lara");
Console.WriteLine("Lara's Age: {0}", lara.Value.Age);
  • Delete a person
redisDictionary.Remove(lara.Key);
  • Delete the Person dictionary from redis
redisDictionary.Clear();
  • Creating a redis list without factory
var redisList = new RedisList<int>(connectionMultiplexer.GetDatabase(), "Numbers");
  • Adding some numbers to redis list and iterate through it
for (int i = 0; i < 10; i++)
{
	redisList.Add(i);
}

foreach (var number in redisList)
{
	Console.WriteLine(number);
}
  • Delete the Numbers list from redis
redisList.Clear();
  • Using a DI container (This sample used Unity)
var container = new UnityContainer();

// Register connectionMultiplexer as a singleton instance
container.RegisterInstance<IConnectionMultiplexer>(connectionMultiplexer);
// Register RedisTypeFactory
container.RegisterType<IRedisTypeFactory, RedisTypeFactory>();
// Resolve an IRedisTypeFacoty
var factory = container.Resolve<IRedisTypeFactory>();

// Get a redis set from factory and add some members to it
var redisSet = factory.GetSet<int>("NumbersSet");
redisSet.Add(1);
redisSet.Add(1);
redisSet.Add(2);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.