7

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

Steffen Opel
  • 63,899
  • 11
  • 192
  • 211
Rob
  • 11,446
  • 7
  • 39
  • 57
  • I managed to connect to ElastiCache with memcache implementation, but describing it will take me a while. But I haven't tried that from Beanstalk... – Łukasz Rżanek Feb 14 '12 at 20:26

1 Answers1

12

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

Anoop Halgeri
  • 662
  • 3
  • 8
  • 17
  • 1
    Don't you also have to add `@Cache` and `@Cachable` annotations for the Hibernate entities that you'd like to cache? – Luke Aug 27 '13 at 16:38