为什么EhCacheProvider不推荐使用? [英] Why is EhCacheProvider deprecated?

查看:1117
本文介绍了为什么EhCacheProvider不推荐使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将hibernate项目配置为使用二级缓存提供程序,这样我就可以利用查询缓存。



我为ehcache添加了一个依赖项:

 <依赖关系> 
< groupId> net.sf.ehcache< / groupId>
< artifactId> ehcache-core< / artifactId>
< version> 2.2.0< / version>
< /依赖关系>

我认为我想使用的提供程序类是:

  net.sf.ehcache.hibernateEhCacheProvider 

当我在eclipse中查看引用的库时,我在 EhCacheProvider 上看到 @Deprecated 注释,并在 SingletonEhCacheProvider 。是什么赋予了?是否有最新的替换供应商,我可以使用?



我使用休眠版本3.4.0.GA,以防万一。

解决方案


什么给了?有没有最新的替代供应商,我可以使用?


他们已被弃用,赞成实施新的类Hibernate 3.3 / 3.5 SPI及其 CacheRegionFactory 。这些实现分别为:


  • net.sf.ehcache.hibernate.EhCacheRegionFactory

  • net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory



新SPI的好处包括:



  • SPI在Hibernate缓存管道中删除了同步。关于如何控制并发访问,在缓存实现
    中剩下

    Ehcache从1.6开始,取消了
    syncrhonization,转而使用CAS
    方法。对于庞大的
    工作负载,结果令人印象深刻。

  • 新的SPI提供对缓存区域存储和
    缓存策略的更好控制。 Ehcache 2.0需要
    的优势来减少内存
    的使用。它提供只读,非严格的
    读写和读写策略,
    所有集群安全。
  • Ehcache 2.0可以很容易地用Terracotta Server Array分配。这
    为您提供集群安全操作
    (一致性),HA和超出进程内缓存
    限制的规模,其中
    是大多数Hibernate用户使用
    的方式Ehcache今天。现有的
    ehcache.jar和ehcache-terracotta.jar
    提供客户端库。 (...)


您因此被鼓励使用新的实现。配置通过以下属性完成:

 < property name =hibernate.cache.region.factory_class> 
net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
< / property>

取代 hibernate.cache.provider_class 属性。

引用




  • Hibernate博客


  • EhCache文档


    I am configuring my hibernate project to use a 2nd-level cache provider, so that I can take advantage of query caching.

    I added a dependency to ehcache:

       <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.2.0</version>
       </dependency>
    

    I think that the provider class I want to use is:

    net.sf.ehcache.hibernateEhCacheProvider
    

    When I look at the referenced libraries in eclipse, I see the @Deprecated annotation on EhCacheProvider, and also on SingletonEhCacheProvider. What gives? Is there an up-to-date replacement provider that I can use?

    I am using hibernate version 3.4.0.GA, in case it matters.

    解决方案

    What gives? Is there an up-to-date replacement provider that I can use?

    They have been deprecated in favor of the classes implementing the new Hibernate 3.3/3.5 SPI with its CacheRegionFactory. These implementations are respectively:

    • net.sf.ehcache.hibernate.EhCacheRegionFactory
    • net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory

    Benefits of the new SPI include:

    • The SPI removed synchronization in the Hibernate cache plumbing. It is left up to the caching implementation on how to control concurrent access. Ehcache, starting with 1.6, removed syncrhonization in favour of a CAS approach. The results, for heavy workloads are impressive.
    • The new SPI provides finer grained control over cache region storage and cache strategies. Ehcache 2.0 takes advantage of this to reduce memory use. It provides read only, nonstrict read write and read write strategies, all cluster safe.
    • Ehcache 2.0 is readily distributable with Terracotta Server Array. This gives you cluster safe operation (coherency), HA and scale beyond the limits of an in-process cache, which is how most Hibernate users use Ehcache today. There is the existing ehcache.jar and ehcache-terracotta.jar which provides the client library. (...)

    You are thus encouraged to use the new implementations. Configuration is done via the following property:

    <property name="hibernate.cache.region.factory_class">
        net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
    </property>
    

    That replaces the hibernate.cache.provider_class property.

    References

    这篇关于为什么EhCacheProvider不推荐使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆