cnblogs / EnyimMemcachedCore

.NET Memcached client. Available on https://www.nuget.org/packages/EnyimMemcachedCore
Apache License 2.0
162 stars 45 forks source link

Unable to fetch Complex object type (List<>), Return unexpected BsonType #149

Closed guptaakshay09 closed 1 year ago

guptaakshay09 commented 4 years ago

Hi Team,

I am facing an issue wherein, the I am trying to set cache via Enyim.Memcached .Net framework assembly and trying to get it via EnyimMemcachedCore assembly.

Before going into the details, I wanted to understand is this achievable. As for primitive data types above scenario works pretty well but not for complex types it won't - for instance: List<>, Dictionary<String, List<>>

Enyim.Memcached version - 2.16.0 EnyimMemcachedCore - 2.4.4, 2.0.0. tried almost 5 of the versions it didn't work Version 2.1.11 : As mentioned in one of the previous issue Issue-79 it says that is resolves Unexpected BsonType error, which is exactly the same I am receiving too.

I debug the code of both above assemblies In Framework: we are using BinaryFomatter while saving and reading for serialization, however In Core: we are first converting to BsonWriter and then serializing

Is that the case, why the above error keeps on appearing as the formatter is not same.

I am using Memcached exe and using windows service to keep it running. Using default port: 11211, and protocol as binary. No other settings specified.

Below is concrete class object I am using to set and get it in Memcached

Class Employee prop string Name prop string employeeID

Even with single list I am not able to set/get.

Could you please guide me what am I missing here, please feel free to let me know for any further details required.

banderberg commented 3 years ago

I have the same issue storing/retrieving IEnumerable of objects.

masterbk commented 1 year ago

I have the same issue storing/retrieving Dictionary of objects.

cnblogs-dudu commented 1 year ago

Introduced MessagePackTranscoder to support complex object type. Please try EnyimMemcachedCore 2.6.0

Add a Transcoder setting to enable MessagePackTranscoder .

{
  "enyimMemcached": {
    "Servers": [
      {
        "Address": "memcached",
        "Port": 11211
      }
    ],
    "Transcoder": "MessagePackTranscoder"
  }
}