<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cache="http://www.springframework.org/schema/cache"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
        http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
    "
>

    <cache:annotation-driven/>

    <!-- <context:annotation-config/> -->

    <!-- the service that you wish to make cacheable. -->
    <bean id="customerDataService" class="org.baeldung.caching.example.CustomerDataService"/>

    <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
        <property name="caches">
            <set>
                <bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" name="directory"/>
                <bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" name="addresses"/>
            </set>
        </property>
    </bean>

    <!-- define caching behavior -->
    <cache:advice id="cachingBehavior" cache-manager="cacheManager">
        <cache:caching cache="addresses">
            <cache:cacheable method="getAddress" key="#customer.name"/>
        </cache:caching>
    </cache:advice>


    <!-- apply the behavior to all the implementations of CustomerDataService  -->
    <aop:config>
        <aop:advisor advice-ref="cachingBehavior" pointcut="execution(* org.baeldung.caching.example.CustomerDataService.*(..))"/>
    </aop:config>

</beans>
