是否有人使用Hlasticnate将Elasticache用作其二级缓存?

时间:2012-01-06 23:39:51

标签: java hibernate amazon-ec2 amazon-elasticache

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

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

1 个答案:

答案 0 :(得分:10)

是的,我们能够使用二级缓存配置hibernate ..虽然不是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