I am trying to implement caching in ASP.Net core app. Currently What I have implemented is In Memory caching using IMemoryCache
but what I want is cache should get invalidated if corresponding record in SQL server 2016 gets changed. One way I found it SQLCacheDependency
but it is not a part of .Net Core as per this link
Any thoughts on this ?
Right now this class hasn't been migrated to the .Net Core, so you can't easily manage out such logic. Probably it will be a part of .Net Standard 2.0, so you either implement some temporary solution with CancellationChangeToken
with direct sql database checks (which is very inefficient) or wait for update.
You could add CancellationChangeToken and then call Cancel method on it, this should evict your record from the in-memory cache. On top of it, there is a PostEvictionDelegate callback available to you (to fire additional actions after the cache record has been evicted). You can read more here: https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.