繁体   English   中英

hibernate中存储的第一级缓存在哪里? 在内存或硬盘?

[英]where is first level cache stored in hibernate? in memory or hard disk?

Hibernate中存储的第一级缓存在哪里? 在内存(RAM)或硬盘? 如果内存少于存储查询的所有行,那么它是如何存储在内存中的呢?在这种情况下它如何管理缓存呢?

Hibernate Session是它的第一级缓存。 它是堆中的对象,因此它在RAM中。 通常你有足够的RAM(> 256MB)来存储查询=)

它在内存中,否则它不会提供任何性能优势。

ehcache memcached hazelcast

通常,高速缓存存储在内存中,但如果使用群集高速缓存,则可以从网络访问高速缓存。

这里列出了Hibernate缓存提供程序及它们之间的区别: Hibernate缓存提供程序

您可以找到其他一些可能使用NoSql键/值引擎来处理缓存的缓存提供程序。

第一级缓存绝对是会话所拥有的RAM,因此它具有性能和易用性优势。

如果您认为加载的对象在会话中太多,您可以在会话关闭之前从一级缓存中删除一些。 请参阅会话界面源代码。

public interface Session extends Serializable {
    ...

    /**
     * Remove this instance from the session cache. Changes to the instance will
     * not be synchronized with the database. This operation cascades to associated
     * instances if the association is mapped with <tt>cascade="evict"</tt>.
     *
     * @param object a persistent instance
     * @throws HibernateException
     */
    public void evict(Object object) throws HibernateException;
}

暂无
暂无

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

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