简体   繁体   English

根据数据表值更改使内存缓存中的C#过期

[英]Expire C# in memory cache on data table value changes

I have ac# app, which caches few data table in memory from sql server database. 我有一个ac#应用,该应用从sql server数据库的内存中缓存了一些数据表。 I have written a thread to update the cache after 30 minutes, but that does not sounds a good solution. 我写了一个线程在30分钟后更新缓存,但这听起来不是一个好的解决方案。 I feel the best solution will be to expire cache on data table data change. 我觉得最好的解决方案将是使缓存在数据表中的数据更改。 Is there any framework that does this by configuration. 是否有任何框架通过配置来做到这一点。 I check Enterprise Cache Liberary but it does not seems to provide eye on data table. 我检查了Enterprise Cache Liberary,但它似乎没有关注数据表。 Do I have to write trigger in database that will update a table that will help my thread to look into it and decide to expire the cache. 我是否必须在数据库中编写触发器,以更新一个表,该表将帮助我的线程查看该表并决定使缓存过期。

Please let me know the best practice for this requirement. 请让我知道此要求的最佳实践。

You are probably looking for SqlDependency/SqlCacheDependency. 您可能正在寻找SqlDependency / SqlCacheDependency。 Not very sure though. 虽然不是很确定。 Check this link here . 在此处检查此链接。 It might be of use to you. 它可能对您有用。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM