I'm maintaining an application using protobuf-net 2.3.3 on a redis server 2.8.2103 using StackExchange.Redis 1.2.6.
For objects like:
[ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
public class Cachable { Foo[] Foos { get; set; } }
When I save using a simple:
using (var memoryStream = new MemoryStream())
{
Serializer.Serialize(memoryStream, cachable);
database.HashSetAsync("category", "key", memoryStream.ToArray());
}
And then retrieve with:
var response = database.HashGet("category", "key");
if (!response.HasValue) return null;
using (var memoryStream = new MemoryStream(response, false))
{
return Serializer.Deserialize<Cachable>(memoryStream);
}
If the cached array Foos had an empty instance, as in new Foo[0], once Cachable is deserialized, the array become null.
This is changing the behavior of some part of application and generating errors.
Is this behavior expected? Is there any way to change it?