🖋️
StackExchange Redis Extensions
  • Home
  • Setup
  • Dependency Injection
  • Configuration
    • C# Configuration
    • Json Configuration
    • XML Configuration
  • Serializers
    • Newtonsoft Json.Net
    • MsgPack
    • System.Text.Json
  • Packages
  • Usage
    • Add, retrieve and remove complex object
    • Replace an object
    • Work with multiple items
    • Custom serializer
  • ASP.NET Core
    • Expose redis information
  • Helpful link
  • License
  • Work with the code
    • Unit tests
  • Usages
Powered by GitBook
On this page
  • Install
  • Setup

Was this helpful?

  1. Serializers

MsgPack

PreviousNewtonsoft Json.NetNextSystem.Text.Json

Last updated 5 years ago

Was this helpful?

MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one extra byte in addition to the strings themselves.

Install

PackageManager:

Install-Package StackExchange.Redis.Extensions.MsgPack
dotnet add package StackExchange.Redis.Extensions.MsgPack
<PackageReference Include="StackExchange.Redis.Extensions.MsgPack" Version="5.5.0" />
paket add StackExchange.Redis.Extensions.MsgPack

Setup

Now that you have installed the package, you can register it into your favourite dependency injection framework:

Example using Microsoft.Extensions.DependencyInjection:

services.AddSingleton<ISerializer, MsgPackObjectSerializer>();

Example using Castle.Windsor:

container.Register(Component.For<ISerializer>()
				.ImplementedBy<MsgPackObjectSerializer>()
				.LifestyleSingleton());

The library used is MsgPack.Cli version 1.0.1. For more information about it, please take a look here

https://github.com/msgpack/msgpack-cli