MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.33k stars 457 forks source link

. net core does not support WithBinarySerializer methods #323

Closed dengyangxi closed 3 years ago

dengyangxi commented 3 years ago

I have two projects operating a redis. One is the . Net framework and the other is the . Net CORE

This causes the. Net framework project to write to a cache . . Net core project that cannot be serialized

But. Net core does not have withbinaryserializer. How can I replace it ?

` #if !NETSTANDARD2

    /// <summary>
    /// Configures a <see cref="BinaryCacheSerializer"/> to be used for serialization and deserialization.
    /// </summary>
    /// <returns>The builder part.</returns>
    public ConfigurationBuilderCachePart WithBinarySerializer()
    {
        Configuration.SerializerType = typeof(BinaryCacheSerializer);
        return this;
    }

    /// <summary>
    /// Configures a <see cref="BinaryCacheSerializer"/> to be used for serialization and deserialization.
    /// </summary>
    /// <param name="serializationFormatter">The <see cref="BinaryFormatter"/> for serialization.</param>
    /// <param name="deserializationFormatter">The <see cref="BinaryFormatter"/> for deserialization.</param>
    /// <returns>The builder part.</returns>
    public ConfigurationBuilderCachePart WithBinarySerializer(BinaryFormatter serializationFormatter, BinaryFormatter deserializationFormatter)
    {
        Configuration.SerializerType = typeof(BinaryCacheSerializer);
        Configuration.SerializerTypeArguments = new object[] { serializationFormatter, deserializationFormatter };
        return this;
    }

#endif `

MichaCo commented 3 years ago

Binary Serialization isn't supported in .NET Core, at least not to that degree that it would work for this library which means you have to use any other serializer. There are a couple build in ones coming in additional NuGets, or you serialize your data yourself and then cache it.

dengyangxi commented 3 years ago

thank you ! !~