有没有人获得Hibernate使用Elasticache作为其二级缓存? [英] Has Anyone Gotten Hibernate to Use Elasticache as its 2nd Level Cache?

查看:140
本文介绍了有没有人获得Hibernate使用Elasticache作为其二级缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现有些线程说这是可行的,但没有找到具体的指令或配置信息。



我也想从Beanstalk做到这一点:应用程序应该通过一个配置指向beanstalk,将配置指向弹性缓存实例的休眠。

解决方案

是的,我们可以配置第二级缓存的hibernate ..不过,不用beanstalk ..这段代码应该可以帮助你。 / p>

 <道具> 
< prop key =hibernate.dialect> org.hibernate.dialect.MySQLDialect< / prop>
< prop key =hibernate.show_sql> false< / prop>
< prop key =hibernate.format_sql> false< / prop>


< prop key =hibernate.generate_statistics> true< / prop>
< prop key =hibernate.cache.use_structured_entries> true< / prop>
<! - prop key =hibernate.hbm2ddl.auto> update< / prop - >
< prop key =hibernate.jdbc.batch_size> 100< / prop>


< prop key =hibernate.cache.provider_class> com.googlecode.hibernate.memcached.MemcachedCacheProvider
< / prop>
<! - 禁用高速缓存 - >
< prop key =hibernate.cache.use_query_cache> true< / prop>
< prop key =hibernate.cache.use_second_level_cache> true< / prop>
< prop key =hibernate.memcached.servers>< elasticachehostname>:11211< / prop>
< prop key =hibernate.memcached.cacheTimeSeconds> 300< / prop>



< prop key =hibernate.memcached.connectionFactory> DefaultConnectionFactory< / prop>
< prop key =hibernate.memcached.clearSupported> false< / prop>


< /道具>

您需要 hibernate memcached jar以及

I found some threads saying this was doable, but did not find specific instructions or config information.

I want to do this from Beanstalk as well: the app should get deployed to beanstalk with a config that points hibernate to the elasticache instance(s).

解决方案

Yes, we were able to configure hibernate with 2nd level cache.. Not with beanstalk though.. This code should help you with it.

<props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.format_sql">false</prop>


            <prop key="hibernate.generate_statistics">true</prop>
            <prop key="hibernate.cache.use_structured_entries">true</prop>
            <!-- prop key="hibernate.hbm2ddl.auto" >update</prop -->
            <prop key="hibernate.jdbc.batch_size">100</prop>


            <prop key="hibernate.cache.provider_class">com.googlecode.hibernate.memcached.MemcachedCacheProvider
            </prop>
            <!-- Cache disabled -->
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.memcached.servers"><elasticachehostname>:11211</prop>
            <prop key="hibernate.memcached.cacheTimeSeconds">300</prop>



            <prop key="hibernate.memcached.connectionFactory">DefaultConnectionFactory</prop>
            <prop key="hibernate.memcached.clearSupported">false</prop>


        </props>

You would need the hibernate memcached jar as well

这篇关于有没有人获得Hibernate使用Elasticache作为其二级缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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