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
4
votes
3 answers

Hibernate second-level cache in orm.xml?

Having been googling for hours, I realize that users can use either xml file(orm.xml, I suppose?) or annotations in JPA, or both of them at the same time. I'm i correct? So, My project use the second-level cache, which is not in the JPA…
Kewei Shang
  • 949
  • 3
  • 11
  • 27
4
votes
1 answer

How to keep only last record in second level cache?

Every second I store a lot of objects Foo but new object is compared to previous. Can I configure NHibernate Second Level Cache to keep only last Foo object or should I implement this myself? Little context: I have object Doo which is cached and…
dariol
  • 1,959
  • 17
  • 26
4
votes
1 answer

Hibernate Second-Level Cache: Does get use it?

I've seen it written that the Hibernate second-level cache is only used when invoking the load method. I can't find any conclusive answers about whether it's used when calling get, which the GenericDAO project we've integrated with uses…
DeejUK
  • 12,891
  • 19
  • 89
  • 169
4
votes
0 answers

Type mismatch on load from second level cache

I have a clustered web app running in asp.net + nhibernate that relies in MemcacheD as its second level cache provider. Everything ran fine for months and today some queries started to give a type mismatch error when loading entities from cache L2.…
Pedro
  • 11,514
  • 5
  • 27
  • 40
4
votes
1 answer

How to refresh second level cache?

How to force reread db data (without evicting second level cache before reading) and then put it to cache. The use case is as following: There is a service, which uses dictionary data. The service experiences high load, so performance is the must. I…
Andrey
  • 6,526
  • 3
  • 39
  • 58
4
votes
1 answer

How do I migrate cache related annotations from Hibernate 3.3.x to 3.6.x

My cache usage on entity Foo looked like this @Entity class Foo { @ManyToOne(fetch = LAZY) @Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) private Boo boo; @OneToMany @Cache(usage =…
Joe
  • 14,513
  • 28
  • 82
  • 144
4
votes
1 answer

Thread spin-waits on time to pass error

Why does this happen with ehcache (latest version)? What should be done to get rid of this issue? This issue occurs when I am trying to do bulk upload of data. 14:38:52,359 INFO [Timestamper] Thread spin-waits on time to pas s. Looped 57 times, you…
Joe
  • 14,513
  • 28
  • 82
  • 144
4
votes
3 answers

Is accessing CPU cache (read and write) through C# possible?

I want to know if there are implemented stuff in C# which allows to access CPU cache. It is just interesting for me but I do not have something to do with the cpu cache at the moment. So I was wondering if it is a system limited access or it is…
Dumbo
  • 13,555
  • 54
  • 184
  • 288
4
votes
2 answers

Rhino.Security: second-level cache is never hit for DetachedCriteria

I've implemented a solution which involves Rhino.Security to manage user/roles/permissions. Since I want to check if a user is authorized to access a controller action, I've implemented a custom action filter: public class AuthorizationAttribute :…
LeftyX
  • 35,328
  • 21
  • 132
  • 193
4
votes
3 answers

AppFabric caching's local cache isnt working for us... What are we doing wrong?

We are using appfabric as the 2ndlevel cache for an NHibernate asp.net application comprising a customer facing website and an admin website. They are both connected to the same cache so when admin updates something, the customer facing site is…
Olly
  • 41
  • 2
4
votes
1 answer

problem in determining whether second level cache is working in hibernate

I am trying to use ehcache in my project.. i have specified the following properties in hibernate config file - config.setProperty("hibernate.cache.provider_class","org.hibernate.cache.EhCacheProvider"); …
Juzer Arsiwala
  • 601
  • 2
  • 10
  • 20
4
votes
1 answer

Clear Hibernate 2nd level Cache

I want to clear cache data from 2nd level cache by calling below method: sessionFactory.getCache().evictEntityRegions(); I just want to know , is there any harm in doing this? For example: What will happen if I try to clear cache in middle of…
4
votes
2 answers

Using Hibernate 2nd Level Cache and Multitenancy

I'm presently using Hibernate with MultiTenancy options (schema per tenant in MySQL... so DB per tenant). We have an implementation of the connection provider and tenant identifier which properly switches DB schemas for us. Great. Now, we want to…
John Ament
  • 11,595
  • 1
  • 36
  • 45
4
votes
3 answers

How to fix java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException when configuring EhCache for Hibernate 5.2.5

I am new to Hibernate and I started learning caching in Hibernate, I want to configure EhCache in my hibernate configuration file. I have added hibernate-ehcache-5.2.5.Final.jar to my build path and here is my hibernate.cfg.xml :
Mykhailo Seniutovych
  • 3,527
  • 4
  • 28
  • 50
4
votes
2 answers

infinispan as second level cache hibernate

Trying to use infinispan as a second level cache for hibernate but always gives me the following error org.infinispan.jmx.JmxDomainConflictException: ISPN000034: There's already a JMX MBean instance type=CacheManager,name="DefaultCacheManager"…