You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes the null value is a significative value and CacheManaget library does not support this case.
I would like manager this behavior.
My suggestion is enable/disable this feature by ICacheManager.Configuration.
Exemple:
cacheManager=CacheFactory.Build("name", settings =>settings.WithMicrosoftMemoryCacheHandle("handle"));// New property... default its false for compatibilitycacheManager.Configuration.AllowNull=true;
In my case, I read params from database and store in memory cache by X minute, but if value does not exists in database, I would like stored this key in memory cache with null value, and reduced sql overhead to try to obtain inexistent value.
This behavior is planned and supported by Microsoft IMemoryCache for example.
Because of the architecture of CacheManager, storing null doesn't work.
For memory caches only, yeah that would not be a problem.
But, because CacheManager has to support distributed caching with serialization, just passing in null will be impossible to compute if the object cache is being used, because you cannot infer the real type if you just pass in null for an object.
If I would redesign the library with a new API, I'd probably drop the object support and have only one non typed cache with a generic interface. And then, nulls could be supported.
Activity
MichaConrad commentedon Dec 20, 2020
Because of the architecture of CacheManager, storing null doesn't work.
For memory caches only, yeah that would not be a problem.
But, because CacheManager has to support distributed caching with serialization, just passing in null will be impossible to compute if the object cache is being used, because you cannot infer the real type if you just pass in null for an
object.If I would redesign the library with a new API, I'd probably drop the object support and have only one non typed cache with a generic interface. And then, nulls could be supported.
But no, for now that's by design.