How can i read/write to the 开发者_如何学JAVAcache for a periode of time i.e 10 seconds and then commit the changes to the database?
I'm not 100% sure for NHibernate but Hibernate 2nd level cache does NOT offer Write-Behind caching, Hibernate just directly writes to the database. I think the same applies to NHibernate. In other words, what you'd like to do is IMO not possible, at least not without modifying NHibernate to write to the 2nd level cache and a persistent async-database-queue. But that would be a really non trivial change and is not going to happen short term.
The changes you make will be committed to the database upon the transaction commit independent of whether they were cached or not. As such, you'd need to avoid committing the transaction for that period of time.
精彩评论