I am trying to understand a strange behavior I have with cache invalidation with the Broadleaf demo.
When I modify product directly in DB, product page displays randomly the cached value or the new value stored in db until the cache expires.
browser: firefox/chrome ( cache is disabled)
demoSite: develop-5.0.x
db: mysql5
There are the steps to reproduce it.
CACHE
============
1) Increase CACHE on site
=================
I have increased the timeToLiveSeconds="360" in bl-override-ehcache.xml for all caches.
Code: Select all
<cache
name="blProducts"
maxElementsInMemory="100000"
eternal="false"
overflowToDisk="true"
timeToLiveSeconds="360">
<cacheEventListenerFactory class="org.broadleafcommerce.common.cache.engine.HydratedCacheEventListenerFactory"/>
</cache>
2) GET Product from Api ENDPOINT
===============
Code: Select all
curl -H "Content-Type: application/json" http://localhost:8080/api/v1/catalog/product/
Code: Select all
{"id":1,"name":"Sudden Death Sauce","longDescription":"As my Chilipals know, ...",...,"manufacturer":"Blair's"]}
As expected I get the value from the database which is "manufacturer":"Blair's"
The value is now stored in cache. ( I have just previously invalidated the cache just to be sure)
3) Change product's value in database
=================================
I change quickly the value of manufacturer directly into the database
Code: Select all
curl -H "Content-Type: application/json" http://localhost:8080/api/v1/catalog/product/1
And i still get "manufacturer":"Blair's" which is perfectly normal as the value is retrieved from the cache.
4) DISPLAY PRODUCT PAGE
============================
But when I go to the product page :
http://localhost:8080/hot-sauces/sudden_death_sauce
It displays randomly "Blair's BBB" or "Blair's" as product's manufacturer property value as I am reloading the page !! (ctrl + F5)
I would expect to get the same value equals to the json value ("blair's") until the cache expires.
5) Cache expiration
==================
After 360 seconds ( = cache expiration or cache invalidation via), everything goes back to normal: the new value ( "Blair's BBB") is always returned in json or browser.
My question is :
How to explain the behavior in step 4. Is it normal ? Is there an other cache mechanism involved ?
Thanks !