How to configure distributed cache in grails (do not use Terracota)

I want to deploy my application (Grails 1.3.5) in two or more tomcats (7.0). I managed to do it without problems, but now I want to use RMI configuration My cache (ehcache).

What I have done so far is to create two ehcache.xml and save them in the lib folder of each tomcat. In the ehcache file I Three caches are declared:

> defaultCache
> org.hibernate.cache.StandardQueryCache
> org.hibernate.cache.UpdateTimestampsCache

Each cache has one RMI replicator. This is great but my question is whether I still have to declare each of my Grails domain classes in the ehcache.xml file. If I do this, I will have the same declaration twice: one in ehcache.xml The other is in the class itself (I have set cache = true in the class);

class Book {
static mapping = {
...
cache true
}
}

Yes Yes, you need to set it in two places. ehcache.xml values ​​configure cache settings, but unless caching is enabled for each domain class (and optional mapping set), they will be ignored.

Usually, you will not use the same settings in the defaultCache block, because each domain class usually requires different settings, for example

 maxElementsInMemory='1000'
eternal='true'
maxElementsOnDisk='0'>

class='net .sf.ehca che.distribution.RMICacheReplicatorFactory'
properties='replicateAsynchronously=false
replicatePutsViaCopy=false,
replicateUpdatesViaCopy=false,
replicatePuts=true,
replicateUpdates=true,
replicateRemovals=true'
/>

I want to deploy me in two or more tomcats (7.0) Application (Grails 1.3.5). I managed to do it without problems, but now I want to configure my cache (ehcache) using RMI.

What I have done so far is to create Two ehcache.xml and save them in the lib folder of each tomcat. In the ehcache file I declared 3 caches:

> defaultCache
> org.hibernate.cache.StandardQueryCache
> org.hibernate.cache.UpdateTimestampsCache

Each cache has an RMI replicator. This is good but my question is whether I still have to declare my each in the ehcache.xml file A Grails domain class. If I do this, I will have the same declaration twice: one in ehcache.xml and the other in the class itself (I have set cache = true in the class);

< p>

class Book {
static mapping = {
...
cache true
}
}

Yes, you need to set it in two places. The ehcache.xml value configures the cache setting, but unless Enable caching for each domain class (and optional set of mappings), otherwise they will be ignored.

Usually, you won’t use the same settings in the defaultCache block because each domain Classes usually require different settings, for example

 maxElementsInMemory='1000'
eternal='true '
maxElementsOnDisk='0'>

class='net.sf.ehcache.distribution.RMICacheReplicatorFactory'
properties='replicateAsynchronously=false
replicatePutsViaCopy=false,
replicateUpdatesViaCopy=false,
replicatePuts=true,
replicateUpdates=true,
replicateRemovals=true'
/>

Leave a Comment

Your email address will not be published.