expiry in ehcache.xml is not working in spring boot 3.1. and jpa hibernate

91 views
Skip to first unread message

Enrique Diaz Gaytan

unread,
Dec 28, 2023, 4:17:33 PM12/28/23
to ehcache-dev
I am using ehcache with spring boot and hibernate 
entities are being cached properly working fine
spring-boot-starter-parent:3.1.5
ehcache:3.10.8
hibernate-core:6.2.13

but  ttl expiry tag is not working neither listener is called, am I missing something?

spring-boot-starter-parent:3.1.5
ehcache:3.10.8
hibernate-core:6.2.13
spring:
  jpa:
    properties:
      jakarta:
        persistence:
          sharedCache:
            mode: ENABLE_SELECTIVE
      hibernate:
        jdbc:
          batch_size: '100'
        cache:
          region.factory_class: org.hibernate.cache.jcache.internal.JCacheRegionFactory
          use_second_level_cache: 'true'
          use_query_cache: 'true'
        javax:
          cache:
            provider: org.ehcache.jsr107.EhcacheCachingProvider
            uri: ehcache.xml
          missing_cache_strategy: fail

<config
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns='http://www.ehcache.org/v3'
    xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
    xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.10.xsd"
>  
 <cache-template name="entitiesDefault">
        <expiry>
            <ttl unit="seconds">60</ttl>
        </expiry>

        <listeners>
            <listener>
                <class>com.config.JpaCacheEventListener</class>
                <event-firing-mode>ASYNCHRONOUS</event-firing-mode>
                <event-ordering-mode>ORDERED</event-ordering-mode>
                <events-to-fire-on>CREATED</events-to-fire-on>
                <events-to-fire-on>EVICTED</events-to-fire-on>
                <events-to-fire-on>EXPIRED</events-to-fire-on>
                <events-to-fire-on>REMOVED</events-to-fire-on>
                <events-to-fire-on>UPDATED</events-to-fire-on>
            </listener>
        </listeners>

        <resources>
            <heap unit="entries">1000</heap>
        </resources>
    </cache-template>

<cache
        alias="com.entity.SecurityStandards"
        uses-template="entitiesDefault">
        <expiry>
            <ttl unit="seconds">60</ttl>
        </expiry>
    </cache>
</config>
Reply all
Reply to author
Forward
0 new messages