CloudStructures 3.3.0

dotnet add package CloudStructures --version 3.3.0                
NuGet\Install-Package CloudStructures -Version 3.3.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="CloudStructures" Version="3.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CloudStructures --version 3.3.0                
#r "nuget: CloudStructures, 3.3.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 CloudStructures as a Cake Addin
#addin nuget:?package=CloudStructures&version=3.3.0

// Install CloudStructures as a Cake Tool
#tool nuget:?package=CloudStructures&version=3.3.0                

CloudStructures

CloudStructures is the Redis client based on StackExchange.Redis.

StackExchange.Redis is very pure and low level library. It's Redis driver like ADO.NET. It's difficult to use it as raw. CloudStructures provides simple O/R (Object / Redis) mapper like Dapper for ADO.NET.

Releases

Support framework

  • .NET 6+
  • .NET Standard 2.0+
  • .NET Framework 4.6.1+

Installation

dotnet add package CloudStructures

Data structures of Redis

CloudStructures supports these Redis data types. All methods are async.

Structure Description
RedisBit Bits API
RedisDictionary<TKey, TValue> Hashes API with constrained value type
RedisGeo<T> Geometries API
RedisHashSet<T> like RedisDictionary<T, bool>
RedisHyperLogLog<T> HyperLogLogs API
RedisList<T> Lists API
RedisLua Lua eval API
RedisSet<T> Sets API
RedisSortedSet<T> SortedSets API
RedisString<T> Strings API

Getting started

Following code is simple sample.

// RedisConnection have to be held as static.
public static class RedisServer
{
    public static RedisConnection Connection { get; }
    public static RedisServer()
    {
        var config = new RedisConfig("name", "connectionString");
        Connection = new RedisConnection(config);
    }
}

// A certain data class
public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}

// 1. Create redis structure
var key = "test-key";
var defaultExpiry = TimeSpan.FromDays(1);
var redis = new RedisString<Person>(RedisServer.Connection, key, defaultExpiry)

// 2. Call command
var neuecc = new Person("neuecc", 35);
await redis.SetAsync(neuecc);
var result = await redis.GetAsync();

ValueConverter

If you use this library, you should implement IValueConverter to serialize your original class. Unless you pass custom IValueConverter to RedisConnection ctor, fallback to SystemTextJsonConverter automatically that is default converter we provide.

How to implement custom IValueConverter

using CloudStructures.Converters;
using Utf8Json;
using Utf8Json.Resolvers;

namespace HowToImplement_CustomValueConverter
{
    public sealed class Utf8JsonConverter : IValueConverter
    {
        public byte[] Serialize<T>(T value)
            => JsonSerializer.Serialize(value, StandardResolver.AllowPrivate);

        public T Deserialize<T>(byte[] value)
            => JsonSerializer.Deserialize<T>(value, StandardResolver.AllowPrivate);
    }
}
using CloudStructures.Converters;
using MessagePack;
using MessagePack.Resolvers;

namespace HowToImplement_CustomValueConverter
{
    public sealed class MessagePackConverter : IValueConverter
    {
        private MessagePackSerializerOptions Options { get; }

        public MessagePackConverter(MessagePackSerializerOptions options)
            => this.Options = options;

        public byte[] Serialize<T>(T value)
            => MessagePackSerializer.Serialize(value, this.Options);

        public T Deserialize<T>(byte[] value)
            => MessagePackSerializer.Deserialize<T>(value, this.Options);
    }
}

Authors

Yoshifumi Kawai is software developer in Tokyo, Japan. Awarded Microsoft MVP (C#) since April, 2011. He's the original owner of this project.

Takaaki Suzuki is software developer in Fukui, Japan. Awarded Microsoft MVP (C#) since July, 2012. He's a contributer who led the .NET Standard support.

License

This library is under the MIT License.

Product 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 was computed.  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.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on CloudStructures:

Package Downloads
RedisServerWrapper

RedisServer Wrapper. use CloudStructure...

Glimpse.CloudStructures.Redis

Redis Profiler for Glimpse. Target is CloudStructures(a Redis Client as wrapped StackExchange.Redis).

CloudStructures.LZ4

JSON+LZ4 ValueConverter for CloudStructures(a Redis Client as wrapped StackExchange.Redis).

CloudStructures-Rx

Redis PubSub to Observable.

CloudStructures.Converters.MessagePack

Provides MessagePackConverter for CloudStructures.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on CloudStructures:

Repository Stars
neuecc/LightNode
Micro RPC/REST Framework built on OWIN
Version Downloads Last updated
3.3.0 10,357 4/7/2024
3.3.0-preview1 99 3/26/2024
3.2.0 82,650 11/17/2021
3.1.0 722 11/11/2021
3.0.2 7,827 5/5/2021
3.0.0 466 4/29/2021
2.3.2 62,354 11/13/2019
2.3.1 1,836 11/2/2019
2.2.0 958 10/23/2019
2.1.0 4,317 3/3/2019
2.0.0 1,013 2/27/2019
1.2.0.1-beta 1,356 4/14/2017
1.2.0 21,810 10/9/2015
1.1.0 5,154 5/26/2015
1.0.0 2,682 2/5/2015
0.6.1 11,726 11/15/2013
0.6.0 1,665 11/14/2013
0.5.1 1,561 8/3/2013
0.5.0 1,563 7/29/2013
0.4.2-beta 1,199 6/18/2013
0.4.1-beta 1,242 6/9/2013
0.4.0-beta 1,292 6/9/2013
0.3.0-beta 1,125 5/8/2013
0.2.4-beta 1,192 4/29/2013
0.2.3-beta 1,225 4/25/2013
0.2.2-beta 1,135 4/25/2013
0.2.1-beta 1,149 4/25/2013
0.2.0-beta 1,156 4/24/2013
0.1.2-beta 1,212 4/23/2013
0.1.1-beta 1,225 4/17/2013
0.1.0-beta 1,145 4/4/2013