Eh Cache 3.6.0 @Cacheable即使在spring boot中的ttl时间设置后也没有到期

loading...


0

我在我的 Spring 季启动应用程序中使用EhCache 3.6.0进行缓存 .

的pom.xml

<dependency>
            <groupId>org.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>3.6.0</version>
        </dependency>

        <!-- Spring Framework Caching Support -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>

ehcache.xml中

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ehcache.xsd"
         updateCheck="true"
         monitoring="autodetect"
         dynamicConfig="true">         

    <cache name="customattributes"
           maxElementsInMemory="100"
           eternal="false"
           overflowToDisk="false"
           timeToLiveSeconds="60"
           timeToIdleSeconds="0"
           memoryStoreEvictionPolicy="LFU"                    
           transactionalMode="off">           
    </cache>    
</ehcache>

ServiceImpl.java

@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
    @Override
    @Cacheable("customattributes")
    public List<custom> getcustom(Long id)
    {
         List<Custom> customList =dao.getAllCustoms();
        return customList;
    }

Application.java

@SpringBootApplication
@EnableCaching
public class LeadApplication
{  
    public static void main(String[] args)
    {
        SpringApplication.run(LeadApplication.class, args);
    }
}

在 Spring 季启动应用程序中设置ttl时间后,请指导我过期缓存 .

loading...

0回答

No Data

评论

暂时没有评论!