Questions tagged [second-level-cache]

Second-level-cache, as the name implies, is a layer of cache that lives between a "primary" cache and a data service/store (relational database, in most cases) to optimize read operations on the service/store. It is different from the primary cache in its lifespan (primary cache being limited to a request lifetime) and capabilities (persist to store, clustering, etc.).

Second-level-cache, as the name implies, is a layer of cache that lives between a "primary" cache and a data service/store (relational database, in most cases) to optimize read operations on the service/store. It is different from the primary cache in its lifespan (primary cache being limited to a request lifetime) and capabilities (persist to store, clustering, etc.).

Second-level-cache is a concept most often encountered in the context of object-persistence frameworks, such as Hibernate. The idea is to allow the persistence engine to maintain a copy of entities that are available in the data service/store so that queries to retrieve them can be fulfilled using a local lookup as opposed to a full roundtrip to the service/store which invariably lives in a different server, thus requiring a network operation and incurring the associated overhead and latency/performance impact.

350 questions
3
votes
1 answer

Hibernate 2nd level cache only write but not read

I have the next two entities Person: @Entity @Table(name = "person") public class PersonDTO implements Serializable { private static final long serialVersionUID = -3859029259805663330L; @Id @Column(name = "person_id") …
ninja
  • 2,908
  • 4
  • 23
  • 30
3
votes
2 answers

SQL exception causes Hibernate second level cache to have stale data with Infinispan as the provider

We are using Infinispan (clustered using JGroups) as our second level cache in our JPA(Hibernate) based application. When a database operation fails, we see that the level-2 cache is stale. For example: 1) Attempt to create a user with login…
Καrτhικ
  • 3,833
  • 2
  • 29
  • 42
3
votes
1 answer

Trying to use Infinispan as a JPA/Hibernate second level cache provider, without success

I would like to use Infinispan to cache repeatedly called queries. I followed this tutorial to set up Hibernate for this: Using Infinispan as JPA-Hibernate Second Level Cache Provider. I followed every step, and while the log shows that Infinispan…
helpermethod
  • 59,493
  • 71
  • 188
  • 276
3
votes
1 answer

"Cached Item Was Locked" causing Select Statement in Hibernate

I am having trouble with getting some caching to work with hibernate exactly the way I would like. I created some example code to replicate this problem I am having. I have one object that contains instances of itself. For instance, a Part that…
mainstringargs
  • 13,563
  • 35
  • 109
  • 174
3
votes
1 answer

Second level cache does not cache filtered collections in NHibernate?

I am configuring 2nd level cache with NHibernate 3.0. 2nd level cache works great for Entities and Collections but I also have some Entities which have filtered collections.
Amitabh
  • 59,111
  • 42
  • 110
  • 159
3
votes
1 answer

NHibernate 2nd Level Cache - Membase MemCache - Multiple Session Factories

I am using multiple databases in a multi-tenant NHibernate application, I was previously using SysCache which worked fine, however I needed to move to Memcache as we are now using a Web Farm. I am actually using Membase server which was very easy to…
Paul Hinett
  • 1,951
  • 2
  • 26
  • 40
3
votes
1 answer

Is it possible to limit the size of Hibernate second-level-cache for a specific entity?

I have a scenario where Hibernate second-level-cache is enabled and I'd like to cache an entity for which 1000 instances are created every day and retained for 8 years but the queries only deal with the most recent 2 days. I would like to avoid…
Καrτhικ
  • 3,833
  • 2
  • 29
  • 42
3
votes
1 answer

Nhibernate and SetCacheable with second level cache

I am using Rhino.Security repository to manage my users/roles. The process of creation, deletion and association works fine but I am facing a problem when I query using one method: GetAssociatedUsersGroupFor. The first time I call the method I don't…
LeftyX
  • 35,328
  • 21
  • 132
  • 193
3
votes
2 answers

Problems with: A soft-locked cache entry was expired by the underlying Ehcache

I'm getting following warning and I have no idea what to do about it. There is about 80000 entries that write this warning into catalina.out log file in tomcat every time the bannedIPs are getting updated: WARNING: Cache package.BannedIP Key…
MatBanik
  • 26,356
  • 39
  • 116
  • 178
3
votes
1 answer

HazelCast distributed second level cache and update invalidation

I am using hibernate 5 and hazelcast 3.5.4. For second level cache I use HazelcastCacheRegionFactory which happens to be the distributed implementation. HazelcastLocalCacheRegionFactory documentation states clearly that in case of an update/delete…
gkatzioura
  • 2,655
  • 2
  • 26
  • 39
3
votes
1 answer

Hibernate cache vs Map - Storage purpose

Let say i have a table which has Master Data seeded 1 time, and rarely it gets updated. It has a flat structure entity, nothing sort of Lazy attributes. Address{ id, country, state, city, pincode, area } Case -1 :…
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116
3
votes
1 answer

understanding hibernate cache

If I have this method in object class: @OneToMany( fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, mappedBy = "object" ) @org.hibernate.annotations.Cascade( {org.hibernate.annotations.CascadeType.SAVE_UPDATE}) @Column( nullable…
Dejell
  • 13,947
  • 40
  • 146
  • 229
3
votes
1 answer

how to cache an entire table using second level entity caching in hibernate.?

I've been banging my head against wall reagrding this issue for over a month. Please Help.. I want to do second level entity caching (using EHcache) in hibernate for few masters table.i followed…
Anushree
  • 41
  • 1
  • 4
3
votes
1 answer

Hibernate : Is it possible to manually add objects to second level cache?

In my project I want to cache few objects but not whole table. So my problem is, is there a API that i could use to manually add objects to hibernate second level cache ? ( Or is there a way to specify table data region for second level cache ? )
Viraj
  • 5,083
  • 6
  • 35
  • 76
3
votes
2 answers

Relying on nhibernate's second level cache vs pushing objects into asp.net session

I have some big entities which are frequently accessed in the same session. For example, in my application there is a reporting page which consist of dynamically generated chart images. For each chart image on this page, the client makes requests to…
Serguzest
  • 1,287
  • 10
  • 18