Cache invalidation problem

Broadleaf Commerce Discussion Forum

Moderator: jocanas

karim.hj
Junior
Junior
Posts: 34
Joined: Mon Jun 27, 2011 4:29 am

Cache invalidation problem

Postby karim.hj » Wed Feb 01, 2017 1:35 pm

Hello Broadleaf' users !

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>


cachejmx.png
cache
cachejmx.png (45.62 KiB) Viewed 193 times


2) GET Product from Api ENDPOINT
===============

Code: Select all

curl -H "Content-Type: application/json" http://localhost:8080/api/v1/catalog/product/
1

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.

screenshot-bbb.png
Blair's bbb
screenshot-bbb.png (247.3 KiB) Viewed 193 times

screenshot-blair.png
Blair expected value
screenshot-blair.png (109.47 KiB) Viewed 193 times


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 !

Return to “Broadleaf Commerce”

Who is online

Users browsing this forum: No registered users and 1 guest