I installed enable_broker on my SQL Server 2008 to use SQLDepndency
I configured my .Net application to use Syscache2 with a cache scope as follows:
<syscache2>
<cacheRegion name="BlogEntriesCacheRegion" priority="High">
<dependencies>
<commands>
<add name="BlogEntries"
command="Select EntryId from dbo.Blog_Entries where ENABLED=1"
/>
</commands>
</dependencies>
</cacheRegion>
</syscache2>
My hbm file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="BlogEntry" table="Blog_Entries">
<cache usage="nonstrict-read-write" region="BlogEntriesCacheRegion"/>
....
</class>
</hibernate-mapping>
I also enabled query caching for queries on BlogEntry
At the first request, the results are cached in the second level cache, as expected.
If I now go over and change the line in blog_entries, everything works as expected, the cache has expired, it receives this message:
2010-03-03 12:56:50,583 [7] DEBUG NHibernate.Caches.SysCache2.SysCacheRegion - Cache items for region 'BlogEntriesCacheRegion' have been removed from the cache for the following reason : DependencyChanged
I expect this. In the query on the next page, the query and results will be stored in the cache. However, the cache is again invalid, even if nothing has changed.
DEBUG NHibernate.Caches.SysCache2.SysCacheRegion - Cache items for region 'BlogEntriesCacheRegion' have been removed from the cache for the following reason : DependencyChanged
- . - , ( , , )
- - , ? , syscache2 SQLDependency onChange, , , , , SQL Server SQLDependency depedencyChanged.