second-level-cache

NHibernate 2nd level caching with AppFabric

若如初见. 提交于 2019-12-18 17:03:03
问题 Has anyone used AppFabric for their second level caching? I know it's to follow the same api as for Velocity (nhibernate.caches.velocity) but wanted to know if anyone already had some production experience of using it and if they knew of any particular tips or problems? 回答1: The only problem I'm currently aware of is what was covered in this question, that the references in the Velocity cache code are out of date and need updating to the AppFabric v1 release assemblies. 回答2: I haven't used

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

What is second level cache in hibernate?

久未见 提交于 2019-12-18 10:09:33
问题 What is second level cache in hibernate ? 回答1: Hibernate comes with three different caches: first level, second level and query cache. The first level cache is the Hibernate Session and is used to track the state of entities during the current Session (or unit of work). This is a transaction-level cache. The second level cache shares entity state across various Session. This is a SessionFactory-level cache. The query cache is used to cache queries (and their parameters) and their results.

Using hibernate 2nd level cache or query cache for lazy fetch queries

我的未来我决定 提交于 2019-12-13 16:17:40
问题 I successfully setup hibernate 3.6.2 to use second level cache, using the ehcache 2.5.2 library. I can see in logs and statistics that entities populate second level caches and that the queries that I want to be cacheable are cached. As I use XML configuration in hbm.xml files, considered classes have a <cache usage="read-write"/> sub-element. The following properties are defined : hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=org.hibernate.cache.EhCacheProvider

Is/Can Hibernate's Second-Level Cache be Used for COUNT() operations?

拥有回忆 提交于 2019-12-13 12:29:47
问题 When using Hibernate and Ehcache as a second-level cache (2LC) implementation, is (or can) this cache used when doing COUNT operations with a WHERE clause? In SQL terms the query I'm performing is SELECT COUNT(id) FROM table WHERE someColumn > 100 . In some instances the value passed will be different each time, sometimes it will always be the same. I'm assuming this is outside of the scope of 2LC, and instead would need to be managed 'manually' (cache the result of the query, and invalidate

How I can disable the second-level cache of some certain entities in Hibernate without changing annotations

大兔子大兔子 提交于 2019-12-13 11:45:02
问题 I'm using Hibernate second level cache in my application, for certain business reason I can't change the entity annotation any more . In my project, apart from changing the Database from Hibernate, there exist also other native SQL that do not go through Hibernate. Therefore, the Hibernate second-level cache data could be stale after database being updated from native SQL. That's why I want to disable the second-level cache for certain entities (programmatically or other way than changing

NoCacheProvider class alternative in Hibernate 4

怎甘沉沦 提交于 2019-12-12 10:31:35
问题 I've just realized that there is no org.hibernate.cache.internal.NoCacheProvider class in Hibernate 4 Core packages. Maybe it is deprecated. So is there any alternive for Hibernate 4? Thank you in advance! 回答1: CacheProvider SPI has been deprecated for quite a long time now (since 3.3 iirc). org.hibernate.cache.internal.NoCachingRegionFactory is the "no caching" equivalent in the new CacheRegionFactory SPI 来源: https://stackoverflow.com/questions/18825643/nocacheprovider-class-alternative-in

Garbage collection when Ehcache is used for hibernate second level cache

让人想犯罪 __ 提交于 2019-12-12 04:32:18
问题 When Ehcache is used for hibernate second level cache, do the objects in echache get garbage collected by the JVM? 回答1: They will eventually get garbage collected... But given you say "the objects in ehcache", I'd be tempted to say... it depends. i.e. for as long as Ehcache deems the data "valuable" and you only have on-heap storage configured, it'll remain on heap. Depending on the version you run and the cache's topology, when not considered "hot" enough anymore to remain on-heap (i.e. as

NHibernate query cache makes one request per row to fetch entities

自古美人都是妖i 提交于 2019-12-11 07:42:15
问题 I'm trying out the second level cache in NHibernate. With this code: return session.Query<Payment>() .Cacheable() .OrderByDescending(payment => payment.Created) .Skip((page - 1)*pageSize) .Take(pageSize).ToArray(); If the entities are not in the cache, it will lead to queries like these being executed: select ... from Payment where Id = 1 select ... from Payment where Id = 2 select ... from Payment where Id = 3 If 100 rows are returned, 100 of these would be executed. I.e. a big performance

nhibernate second level cache with implicit transactions

青春壹個敷衍的年華 提交于 2019-12-11 05:11:55
问题 I've read that we can't use 2nd level caching until we use (explicit) transactions - however, we are using a an Informix system - which for reasons currently beyond our control; an accounting system - we cannot use transactions until we move to SQL server. Second level caching could greatly improve our performance by cache data that doesn't changed often - is there any way at all to use it with implicit transactions? 回答1: No, NH won't use the cache without a transaction. But I really wonder