Lucee ehCache distribution for beginners

I’m trying to configure cache distribution between two instances.

For this I’ve created test appliaction:

Application.cfc

component {
    this.cache.connections["testcache"] = {
        class: 'org.lucee.extension.cache.eh.EHCache',
        bundleName: 'ehcache.extension',
        bundleVersion: '2.10.0.36',
        storage: false,
        custom: [
            "bootstrapAsynchronously":"true",
            "replicatePuts":"true",
            "automatic_hostName":"",
            "bootstrapType":"on",
            "maxelementsinmemory":"20000",
            "manual_rmiUrls":"//10.10.10.10:40001",
            "automatic_multicastGroupAddress":"",
            "distributed":"manual",
            "replicatePutsViaCopy":"true",
            "memoryevictionpolicy":"LRU",
            "maximumChunkSizeBytes":"5000000",
            "timeToIdleSeconds":"21600",
            "automatic_multicastGroupPort":"4448",
            "listener_socketTimeoutMillis":"120000",
            "timeToLiveSeconds":"86400",
            "replicateRemovals":"true",
            "manual_addional":"",
            "replicateUpdatesViaCopy":"true",
            "automatic_addional":"",
            "replicateAsynchronously":"false",
            "maxelementsondisk":"10000000",
            "listener_remoteObjectPort":"",
            "asynchronousReplicationIntervalMillis":"1000",
            "listener_hostName":"",
            "replicateUpdates":"true",
            "manual_hostName":"",
            "automatic_timeToLive":"unrestricted",
            "listener_port":""
        ]
      , default: 'object'
   };
}

index.cfm

<cfscript>
    variables.res = cacheGet('Test');
    if (isNull(variables.res)) {
        variables.res = 'Cache is empty';
    }
    writeOutput(variables.res);
</cfscript>

put.cfm

<cfscript>
    cachePut('Test', 'Hello, World!');

    writeOutput('Cache put!');
</cfscript>

delete.cfm

<cfscript>
    cacheDelete('Test');

    writeOutput('Cache deleted!');
</cfscript>

In Applicationc.cfc on instace A I provide rmiUrls “//inst.ance.B.ip:40001” and on instance B I provide rmiUrls “//inst.ance.A.ip:40001

And now I’m trying to execute put/delete and check cache on both instances but for my no pur neither delete doesn’t synchronized on any of them(

What I’ve missed? What I’m doing wrong?

OS: Windows 10 (10.0) 64bit
Java Version: 11.0.22 (Oracle Corporation) 64bit
Tomcat Version: Apache Tomcat/9.0.86
Lucee Version: 6.0.4.10

Hey did you have any luck getting this working? We’re in a similar position - trying to set up manual replication between two servers, and it’s seemingly not working with any combination of settings. We’ve also tried to enable some logging to see where it’s not working, but couldn’t get that going either.

We’re on Windows 2016/IIS with the latest 6.2.0.321 release and the latest released ehcache extension version.

If you or anyone else has any ideas, they’d be appreciated :slight_smile:

@dswitzer any ideas?

Thanks Zackster. I’ve tried everything I can think of, including different permutations of how to configure the cache, but nothing.

So - is there a way to get any logging out of ehache? I could at least see what it is doing - or not. I tried to follow some instructions online for enabling this in logging.properties, but that didn’t work. Anyone know how to do this?

Other than that, we’ve got a large client and we need to run two servers for the same underlying site to share the load. How do we otherwise implement caching in memory that can at least propagate cache deletions to the other server? Sorry, I’m just not across what people are doing for clustering in this regard. Redis? Something else?

4 posts were split to a new topic: Using Redis as a cache for Lucee

Hi @Volodymyr_Vodnitskyi ,

It should work after you make the following 2 improvements in Application.cfc:

  1. Give the application a name;
  2. Change custom from an array to a struct;

For example,

component {
	this.name = "MyApplication";
	this.applicationTimeout = "#createTimespan(1,0,0,0)#";
	this.sessionManagement = "true";
	this.sessionTimeout = "#createTimeSpan(0,0,30,0)#";

	this.cache.connections["testcache"] = {
		class: 'org.lucee.extension.cache.eh.EHCache',
		bundleName: 'ehcache.extension',
		bundleVersion: '2.10.0.36',
		storage: false,
		custom: {
		    "bootstrapAsynchronously":"true",
		    "replicatePuts":"true",
		    "automatic_hostName":"",
		    "bootstrapType":"on",
		    "maxelementsinmemory":"20000",
		    "manual_rmiUrls":"//10.10.10.10:40001",
		    "automatic_multicastGroupAddress":"",
		    "distributed":"manual",
		    "replicatePutsViaCopy":"true",
		    "memoryevictionpolicy":"LRU",
		    "maximumChunkSizeBytes":"5000000",
		    "timeToIdleSeconds":"21600",
		    "automatic_multicastGroupPort":"4448",
		    "listener_socketTimeoutMillis":"120000",
		    "timeToLiveSeconds":"86400",
		    "replicateRemovals":"true",
		    "manual_addional":"",
		    "replicateUpdatesViaCopy":"true",
		    "automatic_addional":"",
		    "replicateAsynchronously":"false",
		    "maxelementsondisk":"10000000",
		    "listener_remoteObjectPort":"",
		    "asynchronousReplicationIntervalMillis":"1000",
		    "listener_hostName":"",
		    "replicateUpdates":"true",
		    "manual_hostName":"",
		    "automatic_timeToLive":"unrestricted",
		    "listener_port":""
		}, 
                       default: 'object'
	};

}
1 Like