C# Memcached Transcoders
C#
Latest commit 3cef38c Dec 3, 2012 @neuecc add license to ReadMe
Permalink
Failed to load latest commit information.
.nuget
Common
Docs
JsonTranscoder add document Dec 2, 2012
Memcached
MemcachedTranscoder.PerfTest add document Dec 2, 2012
MemcachedTranscoder.Tests
MessagePackMapTranscoder
MessagePackTranscoder add document Dec 2, 2012
ProtoTranscoder add document Dec 2, 2012
.gitignore Add ProtoTranscoder and Tests Nov 14, 2012
MemcachedTranscoder.sln
ReadMe.md

ReadMe.md

MemcachedTranscoder

MemcachedTranscoder is custom transcoders of Enyim.Memcached. It serialize object using Protobuf-net, JSON.NET and MsgPack-Cli.

Install

Install with NuGet.

Install-Package Enyim.Memcached.Transcoders.ProtocolBuffers
Install-Package Enyim.Memcached.Transcoders.Json
Install-Package Enyim.Memcached.Transcoders.MessagePack
Install-Package Enyim.Memcached.Transcoders.MessagePack.Map

Usage

edit transcoder type.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="enyim.com">
            <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
        </sectionGroup>
    </configSections>
    <enyim.com>
        <memcached protocol="Binary">
            <servers>
                <add address="127.0.0.1" port="11211"/>
            </servers>
            <transcoder type="MemcachedTranscoder.ProtoTranscoder, ProtoTranscoder" />
        </memcached>
    </enyim.com>
</configuration>

transcoder variations

<transcoder type="MemcachedTranscoder.ProtoTranscoder, ProtoTranscoder" />
<transcoder type="MemcachedTranscoder.JsonTranscoder, JsonTranscoder" />
<transcoder type="MemcachedTranscoder.MessagePackTranscoder, MessagePackTranscoder" />
<transcoder type="MemcachedTranscoder.MessagePackMapTranscoder, MessagePackMapTranscoder" />

ProtoTranscoder using Protocol Buffers. protobuf-net has official transcoder.But it isn't support generics and primitive collections. This ProtoTranscoder supports.
MessagePackTranscoder serialize array mode(default). MessagePackMapTranscoder serialize map mode.

Performance

Serialization, Deserialization speed and size test.
Note::This isn't serializer test. This contains overhead of transcode.

[ProtoContract]
[Serializable]
public class TestClass
{
    [ProtoMember(1)]
    [MessagePackMember(0)]
    public string MyProperty1 { get; set; }
    [ProtoMember(2)]
    [MessagePackMember(1)]
    public int MyProperty2 { get; set; }
    [ProtoMember(3)]
    [MessagePackMember(2)]
    public DateTime MyProperty3 { get; set; }
    [ProtoMember(4)]
    [MessagePackMember(3)]
    public bool MyProperty4 { get; set; }
}

// Simple POCO
var obj = new TestClass
{
    MyProperty1 = "hoge",
    MyProperty2 = 1,
    MyProperty3 = new DateTime(1999, 12, 11, 0, 0, 0, DateTimeKind.Utc),
    MyProperty4 = true
};

// Array
var array = Enumerable.Range(1, 10)
    .Select(i => new TestClass
    {
        MyProperty1 = "hoge" + i,
        MyProperty2 = i,
        MyProperty3 = new DateTime(1999, 12, 11, 0, 0, 0, DateTimeKind.Utc).AddDays(i),
        MyProperty4 = i % 2 == 0
    })
    .ToArray();

speed of 100000 iteration(size is single).

S is Serialize(millisecond)
D is Deserialize(millisecond)
Size is byte

Simple POCO************************
S DefaultTranscoder:735
D DefaultTranscoder:750
Size:305
S DataContractTranscoder:775
D DataContractTranscoder:1642
Size:746
S ProtoTranscoder:99
D ProtoTranscoder:142
Size:88
S JsonTranscoder:772
D JsonTranscoder:892
Size:167
S MessagePackTranscoder:256
D MessagePackTranscoder:535
Size:89
S MessagePackMapTranscoder:327
D MessagePackMapTranscoder:783
Size:137

Array******************************
S DefaultTranscoder:4234
D DefaultTranscoder:4186
Size:712
S DataContractTranscoder:3874
D DataContractTranscoder:9532
Size:4525
S ProtoTranscoder:2189
D ProtoTranscoder:3040
Size:255
S JsonTranscoder:5618
D JsonTranscoder:6275
Size:1043
S MessagePackTranscoder:752
D MessagePackTranscoder:2696
Size:256
S MessagePackMapTranscoder:1453
D MessagePackMapTranscoder:5088
Size:736

DefaultTranscoder = BinaryFormatter
DataContractTranscoder = NetDetaContractSerializer

license

Apache License 2.0