7.4 EvictInterceptor

更新于 11-28 20:02 · 约 425 字 · 阅读 10

    EvictInterceptor可以根据CacheName注解自动清除缓存。以下是示例代码:

@Before(EvictInterceptor.class)
@CacheName("blogList")
public void update() {
    getModel(Blog.class).update();
    redirect("blog.html");
}

    上例中的用法将清除cacheName为blogList的缓存数据,与其配合的CacheInterceptor会自动更新cacheName为blogList的缓存数据。

     jfinal 3.6 版本支持 @CacheName 参数使用逗号分隔多个 cacheName,方便针对多个 cacheName 进行清除,例如:

@Before(EvictInterceptor.class)
@CacheName("blogList, hotBlogList")   // 逗号分隔多个 cacheName
public void update() {
   ...
}


顶部