Quantcast

How to verify Grails 2.1.0 Hibernate L2 Cache?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to verify Grails 2.1.0 Hibernate L2 Cache?

Sami
This post was updated on .
I am using Grails 2.1.0. I have been trying to verify/profile my L2 cache. Now, I doubt that hibernate/cache settings are correct.

• I have enabled generate_statistics in the hibernate settings located in conf\DataSource.grooy.


    hibernate {
        generate_statistics = true
        cache.use_second_level_cache = true
        cache.use_query_cache = true
        cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
        format_sql = true
        use_sql_comments = true
    }

• I have enabled the cache in the domain mapping.


    package com.att.failbox.log.cause
    class LogCauseMemento {
        Date dateCreated
        static mapping = {
            version false
            id generator: 'assigned'
            table 'log_cause'
            cache: true
        }
    }

• I have added the corresponding entry the domain entry in ehcache.xml


    <?xml version="1.0" encoding="UTF-8"?>
    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="ehcache.xsd" >
    <diskStore path="java.io.tmpdir"/>
    <cacheManagerEventListenerFactory class="" properties=""/>
    <defaultCache
        eternal="false"
        timeToLiveSeconds="3600"
        overflowToDisk="false"
        diskPersistent="false"
        />
    <cache name="com.att.failbox.log.cause.LogCauseMemento"
        maxElementsInMemory="100000"
        eternal="true"
        />
    </ehcache>

• However, when I try to verfy the L2 cache using “stats.getSecondLevelCacheRegionNames()” I am only getting “StandardQueryCache, UpdateTimestampsCache”.


    import org.hibernate.stat.Statistics
    class DomainProfilerService {
        def sessionFactory
        def displayStatistics() {
            Statistics stats = sessionFactory.getStatistics()
            def names = stats.getSecondLevelCacheRegionNames()
            names.each(){ println it }
        }
    }

Am I looking into the correct place to verify my L2 cache?

DataSource.groovy
ehcache.xml
Config.groovy
LogCauseMemento.groovy
DomainProfilerService.groovy
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to verify Grails 2.1.0 Hibernate L2 Cache?

Joel Richon
Not sure if it matters, but the documentation shows 'cache true' with no
colon.

Cheers
   Joel

On 7/24/2012 3:33 PM, Sami wrote:

> *• I have enabled the cache in the domain mapping.*
>
>
>      package com.att.failbox.log.cause
>      class LogCauseMemento {
>          Date dateCreated
>          static mapping = {
>              version false
>              id generator: 'assigned'
>              table 'log_cause'
>              cache: true
>          }
>      }
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to verify Grails 2.1.0 Hibernate L2 Cache?

Sami
@ Joel
Thanks Joel, you are correct.  the colon was the problem.  I also think that using Groovy 1.8 with Grails 2.1.0 might contributed to the problem as well.

thanks again,

Sami
Loading...