Allow null values pattern #343
-
Hi, Sometimes the null value is a significative value and CacheManaget library does not support this case. Exemple: cacheManager = CacheFactory.Build("name", settings => settings.WithMicrosoftMemoryCacheHandle("handle"));
// New property... default its false for compatibility
cacheManager.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. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Because of the architecture of CacheManager, storing null doesn't work. 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. |
Beta Was this translation helpful? Give feedback.
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.