spring-cache-interceptors
© Pongnathee Kluaythong/123RF.COM
Requirements
- Java 8 or later
- Spring Framework
Supported Spring Framework versions
Spring Framework versions | Spring Boot versions | The library version |
---|---|---|
5.3 | 2.4, 2.5 | 0.2.0 |
5.2 | 2.2, 2.3 | 0.1.3 |
Getting started
The library is published to jcenter.
repositories {
mavenCentral()
}
depepdencies {
implementation 'moe.pine:spring-cache-interceptors:0.1.2'
}
Usage
You can create a new interceptor with Spring Framework as following.
import moe.pine.spring.cache.interceptors.CacheInterceptor;
import moe.pine.spring.cache.interceptors.CachePolicy;
import moe.pine.spring.cache.interceptors.CachePolicyBuilder;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
final CachePolicy cachePolicy = new CachePolicyBuilder()
.public_()
.maxAge(3600L)
.build();
final CacheInterceptor cacheInterceptor = new CacheInterceptor(cachePolicy);
registry
.addInterceptor(cacheInterceptor)
.addPathPatterns("/**");
}
}
Development
Test
$ ./gradlew clean check
Upload Maven Central
$ ./gradlew clean publish
License
MIT © Pine Mizune