【问题标题】:Has Anyone Gotten Hibernate to Use Elasticache as its 2nd Level Cache?有没有人让 Hibernate 使用 Elasticache 作为其二级缓存?
【发布时间】:2012-02-04 15:49:24
【问题描述】:

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

我也想从 Beanstalk 执行此操作:应用程序应部署到 beanstalk,并使用将 hibernate 指向 elasticache 实例的配置。

【问题讨论】:

  • 我设法通过 memcache 实现连接到 ElastiCache,但描述它需要一段时间。但我还没有从 Beanstalk 中尝试过...

标签: java hibernate amazon-ec2 amazon-elasticache


【解决方案1】:

是的,我们能够使用二级缓存配置休眠。但不是使用 beanstalk。这段代码应该可以帮助您。

<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>

你还需要hibernate memcached jar

【讨论】:

  • 您是否还必须为要缓存的 Hibernate 实体添加 @Cache@Cachable 注释?
猜你喜欢
  • 2016-04-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-16
  • 2013-02-26
  • 2016-04-18
  • 2015-05-14
  • 1970-01-01
相关资源
最近更新 更多