Is it possible to register the distributed cache and backplane with fusioncache? #468
-
Hi, first of all. Great project for the caching issue. Appreate for the work I'm doing a PoC of our internal project. There is one scenario that we want to do manual cache invalidation upon receiving event sent from the DB (yes, this is our way to ensure that the cache invalidation is 100% robust in the distributed system). We have a different worker project in background monitoring the DB event and act reactively. Is it possible to register distributed cache and the backplane but completly skipping in-memory cache registration? Apparently it is just a worker so no incoming request and we don't need to spare a chunk of memory of holding the caching data nor being synced by the backplane. Or even further the backplane is only for publishing the message instead of receiving one Correct me if I'm wrong, but currently what I'm trying to do is services
.AddFusionCache()
.WithDefaultEntryOptions(options =>
{
options.SetSkipMemoryCache();
})
.WithDistributedCache(new Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache(new RedisCacheOptions() { Configuration = redisCacheSettings.ConnectionString }))
.WithSerializer(new FusionCacheSystemTextJsonSerializer())
.WithBackplane(new RedisBackplane(new RedisBackplaneOptions { Configuration = redisCacheSettings.ConnectionString })); My understanding this omits the memoery read and write at all, but I'm not sure if it will cause some unexpected side-effect so I would like to confirm with the author. Btw, a different small question irrelavent to this topic. Is it possibel to extend the cache operation to allow we remove a list of keys with single async call? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @jundayin
Thanks!
No it's not possible to completely skip the registration at all, but as you pointed out below it's possible to skip the memory cache at every operation (more below).
This reminds me of this issue by some time ago, which sparked the addition of a new options called
This seems correct, and as said an extra something to set would be services.AddFusionCache()
.WithOptions(options =>
{
options.IgnoreIncomingBackplaneNotifications = true;
})
.WithDefaultEntryOptions(options =>
{
options.SetSkipMemoryCache();
})
.WithDistributedCache(...)
.WithSerializer(...)
.WithBackplane(...); This should do the trick.
No, not that I can think of.
Not possible, because at a fundamental level the operations FusionCache can rely on are the ones available in the Hope this helps, let me know! |
Beta Was this translation helpful? Give feedback.
Hi @jundayin
Thanks!
No it's not possible to completely skip the registration at all, but as you pointed out below it's possible to skip the memory cache at e…