geffchang
geffchang

Reputation: 3340

How can I disable ehcache or all types caching?

Hybris: 6.3.0.0-SNAPSHOT

I'm doing performance testing, and I need to disable caching. I've already disabled the database (mySQL) caching and would like to disable all forms of application caching. Is it possibe?

I've already seen other questions and the suggestion to use setDisableCaching for FlexibleSearch. Unfortunately, there are some FlexibleSearch that are under the control of Hybris, and I can't change the method directly. I'm looking to override it next, but I want to know if there's an easier way.

I've also tried adding "-Dnet.sf.ehcache.disabled=true" to tomcat.generaloptions in local.properties, but the application just seems to hang during startup, and the server never starts.

Additional context: We have a web service that is returing 3,000 PointOfService records. The first call is so slow, the Client thinks the application is not working (it might have timed out). The succeeding calls are faster, because the data has already been cached. I need to check how to improve the performance of the first call.

Upvotes: 0

Views: 1813

Answers (4)

alain.janinm
alain.janinm

Reputation: 20065

The new cache is Region Cache.

If you want to disable the cache you have to set the size of all regioncache to 0. It won't be really disabled but nothing will be cached.

You can disable it using code as mentionned in other response Registry.getCurrentTenant().getCache().setEnabled(false);

You can use old cache by setting in your local.properties cache.legacymode=true. This won't disable all cache however.

Now if your problem is low time response when querying a lot of object maybe you need to define your own cache region and set the proper values in your properties :

<alias name="defaultMyObjectCacheRegion" alias="myObjectCacheRegion"/>
<bean name="defaultMyObjectCacheRegion" class="de.hybris.platform.regioncache.region.impl.EHCacheRegion">
    <constructor-arg name="name" value="MyObjectCacheRegion" />
    <constructor-arg name="maxEntries" value="${regioncache.myObjectcacheregion.maxentries}" />
    <constructor-arg name="evictionPolicy" value="${regioncache.myObjectcacheregion.evictionpolicy}" />
    <constructor-arg name="statsEnabled" value="${regioncache.stats.enabled}" />
    <constructor-arg name="exclusiveComputation" value="${regioncache.exclusivecomputation}" />
    <property name="handledTypes">
        <array>
            <value>[MyObject typecode]</value>
        </array>
    </property>

To conclude you should not try to disable hybris cache it's almost impossible. But you can easily clear it for testing purpose. If you have performance issue, I suggest you also take a look a DB transaction. This is often a bottleneck. See : https://help.hybris.com/1808/hcd/8c7387f186691014922080f2e053216a.html

Upvotes: 2

Johannes von Zmuda
Johannes von Zmuda

Reputation: 1822

Did you consider adding a pagination to the call for PointOfService? Let the client request only 10/100 elements at a time. The client then can subsequently request the first 10, second 10... elements. That way the call will be a lot faster. It also wont cram your cache and stress server and database that much. Also the client will be much safer on his processing of the data.

Upvotes: 1

HybrisHelp
HybrisHelp

Reputation: 5810

Run the below as groovy script in commit mode from HAC

tenant.getCurrentTenant().getCache().setEnabled(false);

To reenable it, change false to true.

Upvotes: 1

Farrukh Chishti
Farrukh Chishti

Reputation: 8447

You can manually delete Hybris cache from- https://localhost:9002/hac/monitoring/cache

Upvotes: 1

Related Questions