Page 1 of 1

How to turn on caching?

Posted: Mon Nov 18, 2013 8:26 pm
by pokemon007
I followed the comments in site applicationContex.xml and uncommented following section:
<!-- Delete this bean to enable caching - leaving it on for development is recommended -->
<!-- as it will allow changes made in the admin or directly on the database to be reflected -->
<!-- immediately. However, caching is obviously beneficial in production. -->
<!-- <bean id="blMergedCacheConfigLocations" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<list>
<value>classpath:bl-override-ehcache.xml</value>
</list>
</property>
</bean>
-->

But it seems the queries still happen every time. I also tried to update bl-override-ehcache.xml to use meaningful caching params. Doesn't help either. There seems some other flag that I need to turn on. Please help~

Thank you!

Re: How to turn on caching?

Posted: Tue Nov 19, 2013 2:03 am
by phillipuniverse
If you comment out that bean then that means that you're fine with the OOB Broadleaf caching which is defined in https://github.com/BroadleafCommerce/Br ... hcache.xml.

What I would recommend is to use bl-override-ehcache.xml (so uncomment that bean) and modify the values within that. You can use our bl-ehcache as a guide.

If you can give any more information with those queries continuing to execute that would be helpful. This should work out of the box as I described unless there is a bug somewhere.

Re: How to turn on caching?

Posted: Tue Nov 19, 2013 3:54 am
by pokemon007
Hi Phillip,

Thank you for the response. I've tried to uncommented that fake caching section, too, with updated bl-override-cache.xml starting with OOTB copy. For instance, most my beans are defined as blStandardElements and following is the definition of this element:

<cache
name="blStandardElements"
maxElementsInMemory="100000"
eternal="true"
overflowToDisk="true">
<cacheEventListenerFactory class="org.broadleafcommerce.common.cache.engine.HydratedCacheEventListenerFactory"/>
</cache>

I set blPU.hibernate.show_sql=true so I can see if the query goes to database or to cache. I hit a product page
/{category}/{product.urlKey} that displays a product, (declared as @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region="blStandardElements"), query on db happens which is expected. When I refresh the page, it hits the db again. Don't know where it goes wrong.

Thank you for your help!

-Charlie