syscache2

Can I use NHibernate SysCache with Non-Web-Application?

风流意气都作罢 提交于 2020-01-05 04:39:07
问题 I have a Windows Service which is using NHibernate (3) and SQL Server 2008. WPF-Clients are connecting over WCF to this Service for using DataAccess. My question is now: Can I use SysCache or SysCache2 in this Scenario - or are they only usable in Web-/ASP.NET-Applications? 回答1: Yes, it works just fine. You can use it even in a console app if you want to (provided the computer has the full .NET Framework installed and not just the Client Profile). 来源: https://stackoverflow.com/questions

How to clear the entire second level cache in NHibernate

帅比萌擦擦* 提交于 2019-12-18 10:19:57
问题 I wish to clear the entire second level cache in NHibernate via code. Is there a way to do this which is independent of the cache provider being used? (we have customers using both memcache and syscache within the same application). We wish to clear the entire cache because of changes external to the database may have occurred (and we have no guarantees re: which tables/entities were affected, so we have to assume the worst). 回答1: This should do: sessionFactory.EvictQueries(); foreach (var

NHibernate SysCache2 - dependency breaks cache

岁酱吖の 提交于 2019-12-11 11:08:04
问题 Company class: class Company { public virtual int Id { get;set;} public virtual string Name { get;set;} public virtual int IntProp { get;set;} } Companies table: CREATE TABLE Companies ( Id INT PRIMARY KEY, Name NVARCHAR(50) NOT NULL, IntProp INT NULL ); Here is my web.config: <syscache2> <cacheRegion name="RefData"></cacheRegion> <cacheRegion name="Company"> <dependencies> <commands> <add name="CompanyCommand" command="SELECT * FROM Companies WHERE Deleted = 0" /> </commands> </dependencies>

How to clear the entire second level cache in NHibernate

偶尔善良 提交于 2019-11-29 21:07:46
I wish to clear the entire second level cache in NHibernate via code. Is there a way to do this which is independent of the cache provider being used? (we have customers using both memcache and syscache within the same application). We wish to clear the entire cache because of changes external to the database may have occurred (and we have no guarantees re: which tables/entities were affected, so we have to assume the worst). This should do: sessionFactory.EvictQueries(); foreach (var collectionMetadata in sessionFactory.GetAllCollectionMetadata()) sessionFactory.EvictCollection

How do I make NHibernate cache fetched child collections?

半世苍凉 提交于 2019-11-29 02:33:17
问题 I've got a fairly simple criteria query that fetches child collections, like so: var order = Session.CreateCriteria<Order>() .Add(Restrictions.Eq("Id", id)) .SetFetchMode("Customer", FetchMode.Eager) .SetFetchMode("Products", FetchMode.Eager) .SetFetchMode("Products.Category", FetchMode.Eager) .SetCacheable(true) .UniqueResult<Order>(); Using NH Prof, I've verified that this makes just one round trip to the database (as expected) with a cold cache; however, on successive executions, it