Closed fabionaspolini closed 3 years ago
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.
Hi,
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:
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.