문제

How to set L1 or L2 cache size-limitation. I concern of increasing the cache-size. One way is defining timeout for cache but i want to know is it possible to make a constraint for cache size or not?

RGDS Navid

도움이 되었습니까?

해결책

How to set L1 cache size-limitation

You can't. The only option is to clear the persistence context manually at regular intervals if you want to "control" (actually, clear is very aggressive, it removes all entities) its size.

How to set L2 cache size-limitation

This depends on the underlying cache provider. In other words, this is done by configuring the L2 cache implementation. For example, EHCache has a maxElementInMemory parameter.


what happens in L1?! how much entities will be in the memory as time pass? w/o any constrains ?!

As much as you put in it, until an eventual OutOfMemoryError, hence the need to clear explicitly:

  • on large batch jobs (even if they occur in a single transaction)
  • if a long-lived EntityManager is used

But the usual pattern is to use a short-lived EntityManager and most use cases are not batch jobs so this is not a concern.

See also

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top