NHibernate + SysCache2 + SqlCacheDependency - Cache not invalidating in application

1.1k views Asked by At

I have a basic MVC application that is using NHibernate for OR/M and data access, SysCache2 for the second-level cache in NHibernate, and SqlCacheDependency for the underlying cache invalidation logic. I believe I have everything setup correctly (I can add details if requested) and I can see that items are getting cached on the application side.

However, if I update items in the database table directly, no update is ever sent back up to the application through the SqlCacheDependency and to the SysCache2 in NHibernate. So, data is being updated in the database and is different from what is in the cache in the application (in NHibernate with SysCache2).

I can see the value for the [changeId] column correlating to the correct domain table incrementing in the [AspNet_SqlCacheTablesForChangeNotification] table so I'm fairly certain the SQL Service Broker is setup and configured correctly. If I profile the database with SQL Profiler, I can see the setup calls for queues, services, and sprocs as well as the BEGIN CONVERSATION calls for monitoring.

Not really sure what to check next. Has anyone had this issue before and what was the resolution?

1

There are 1 answers

0
longda On BEST ANSWER

Turns out the primary issue was the sql driver I was using did not support batches. Once I switched it back to the default nhibernate sql 2008 driver everything went swimingly.