B
B
Biaci_Anj2021-08-31 16:18:43
Java
Biaci_Anj, 2021-08-31 16:18:43

What happens when I specify a non-existent Ehcache cache in Cacheable?

For example, here is my XML, there is only 'dto' cache

<config

        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
        xmlns='http://www.ehcache.org/v3'
        xmlns:jsr107='http://www.ehcache.org/v3/jsr107'>

<service>
        <jsr107:defaults enable-statistics="true"/>
    </service>

    <cache alias="dto">
        <key-type>java.lang.Long</key-type>
        <value-type>com.javadevjournal.data.Customer</value-type>
        <expiry>
            <ttl unit="seconds">10</ttl>
        </expiry>
        <listeners>
            <listener>
                <class>com.topjava.graduation.restaurant.logger.CacheLogger</class>
                <event-firing-mode>ASYNCHRONOUS</event-firing-mode>
                <event-ordering-mode>UNORDERED</event-ordering-mode>
                <events-to-fire-on>CREATED</events-to-fire-on>
                <events-to-fire-on>UPDATED</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>EVICTED</events-to-fire-on>
            </listener>
        </listeners>
        <resources>
            <heap unit="entries">2000</heap>
            <offheap unit="MB">100</offheap>
        </resources>
    </cache>
</config>


I also set @EnableCache, that's how everything works fine But I was wondering why everything works even when I specify a cache that does not exist? Does it create a new cache automatically? If so, with what settings and where can I see all the caches?
@Cacheable("dto")

@Cacheable("randomName")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question