Skip to content

JSON serialization not working with Hybrid configuration #334

@gordon-matt

Description

@gordon-matt

I was trying to use JSON serialization instead (as mentioned here: #253). But it throws an exception like: InvalidOperationException: Sequence contains no matching element.

This is my setup:

services.AddEasyCaching(option =>
{
    option.UseInMemory("Memory");

    option.WithJson("JsonSerialization"); // Store as JSON, so we don't need to mark everything with [Serializable]

    // distributed
    option.UseRedis(config =>
    {
        config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
        config.SerializerName = "JsonSerialization";
        //config.DBConfig.Database = 5;
    }, "Redis");

    // combine local and distributed
    option.UseHybrid(config =>
    {
        config.TopicName = "test-topic";
        config.EnableLogging = true;

        // specify the local cache provider name after v0.5.4
        config.LocalCacheProviderName = "Memory";
        // specify the distributed cache provider name after v0.5.4
        config.DistributedCacheProviderName = "Redis";
    }, "Hybrid")
    .WithRedisBus(busConf =>
    {
        busConf.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6380));
    });
});

It works perfectly if I don't have the WithJson("JsonSerialization") and config.SerializerName = "JsonSerialization".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions