带有外部更新的 NHibernate 二级缓存

标签 nhibernate caching syscache

我有一个 99% 只读的 web 应用程序,有一个单独的服务,它以特定的时间间隔(比如每 10 分钟)更新数据库。该服务如何告诉应用程序使其二级缓存无效?其实重要吗? (我实际上并不关心我是否有太多陈旧数据)如果我不使缓存无效,记录更新需要多少时间(如果使用 SysCache)

最佳答案

您可以为特定实体、实体类型或集合手动处置二级缓存。

来自 http://knol.google.com/k/fabio-maulo/nhibernate-chapter-16-improving/1nr4enxv3dpeq/19#

For the second-level cache, there are methods defined on ISessionFactory for evicting the cached state of an instance, entire class, collection instance or entire collection role.

sessionFactory.Evict(typeof(Cat), catId); //evict a particular Cat
sessionFactory.Evict(typeof(Cat));  //evict all Cats
sessionFactory.EvictCollection("Eg.Cat.Kittens", catId); //evict a particular collection of kittens
sessionFactory.EvictCollection("Eg.Cat.Kittens"); //evict all kitten collections

关于带有外部更新的 NHibernate 二级缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2985749/

相关文章:

caching - NHibernate SysCache 不缓存子对象

c# - NHibernate: Invalid Cast(检查你的映射属性类型不匹配);

c# - 在 NHibernate 中设置超时过期

cakephp - 如果缓存服务器(redis)发生故障,如何保持网站运行

c# - 我如何在 nhibernate 中为 syscache 配置缓存区域?

nhibernate - 使用 NHibernate/Fluent Nhibernate 强制插入身份

NHibernate + ViewModel +MVC + 乐观锁

ruby-on-rails - Rails 4 - 有没有办法压缩大图像以使其加载速度更快?

php - 禁用 php 文件缓存以进行调试