Closed jimmycartrette closed 3 hours ago
I think the default JsonSerializerSettings needs DefaultValueHandling to be set:
var serializer = new FusionCacheNewtonsoftJsonSerializer(new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Auto,
DefaultValueHandling = DefaultValueHandling.Include
});
Hi @jimmycartrette , yes I was about to suggest looking into the configuration of the specific serializer. Glad it now works.
Just to be clear, regarding the code above which one is:
var maybeValue = _cache.TryGet<bool>(GetKeyName(key));
-> bool
var maybeValue = _cache.TryGet<bool?>(GetKeyName(key));
-> bool?
I want to doublecheck something...
The first one, not a nullable value type
What I thought: I don't if this is exactly the case, but in general if you try do deserialize null
into a bool
you will have an exception.
I'm just getting started with plugging FusionCache to replace our existing cache systems. I'm calling this: _cache.Set(GetKeyName(key), obj, expiresIn); With obj being a bool. When it's brought back: var maybeValue = _cache.TryGet(GetKeyName(key));
Of type bool, I get a nullreferenceexception.
Trying to dig into the cache itself, it has no "v" or value:
A good entry looks like this: 1) "absexp" 2) "638656608619653733" 3) "data" 4) "{\"v\":true,\"m\":{\"e\":\"2024-10-27T21:21:01.9653733+00:00\"},\"t\":638656572619653733}" 5) "sldexp" 6) "-1"
Any idea what could be going wrong? Using newtonsoft serializer, redis backplane/L2