简体   繁体   English

哪些类在休眠状态下缓存在二级缓存中

[英]Which Classes are Cached in second level cache in hibernate

有没有办法让我找出休眠的二级缓存中缓存了哪些类(即不同类型的实例)。

The second level cache doesn't cache instances of entities, it caches a "dehydrated" version of entities. 二级缓存不缓存实体的实例 ,而是缓存实体的“脱水”版本。 This is well explained in this blog post : 这篇博客文章对此进行了很好的解释:

The 2nd level cache 第二级缓存

The hibernate cache does not store instances of an entity - instead Hibernate uses something called dehydrated state. 休眠缓存不存储实体的实例-而是休眠使用一种称为脱水状态的东西。 A dehydrated state can be thought of as a deserialized entity where the dehydrated state is like an array of strings, integers etc and the id of the entity is the pointer to the dehydrated entity. 可以将脱水状态视为反序列化实体,其中脱水状态就像字符串,整数等的数组,并且实体的id是指向脱水实体的指针。 Conceptually you can think of it as a Map which contains the id as key and an array as value. 从概念上讲,您可以将其视为包含id作为键和一个数组作为值的Map。 Or something like below for a cache region: 或如下所示的缓存区域:

 { id -> { atribute1, attribute2, attribute3 } } { 1 -> { "a name", 20, null } } { 2 -> { "another name", 30, 4 } } 

If the entity holds a collection of other entities then the other entity also needs to be cached. 如果该实体持有其他实体的集合,则该另一个实体也需要被缓存。 In this case it could look something like: 在这种情况下,它可能类似于:

 { id -> { atribute1, attribute2, attribute3, Set{item1..n} } } { 1 -> { "a name", 20, null, {1,2,5} } } { 2 -> { "another name", 30, 4, {4,8} } } 

Depending on the L2 cache provider you're using, you might get some console to monitor/browser the cache but, still, you won't see "instances". 根据您使用的L2缓存提供程序,您可能会得到一些控制台来监视/浏览缓存,但是仍然看不到“实例”。

Resources 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM