Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pine/spring-cache-interceptors
:herb: Cache interceptors for SpringFramework
https://github.com/pine/spring-cache-interceptors
java spring-boot spring-framework
Last synced: 26 days ago
JSON representation
:herb: Cache interceptors for SpringFramework
- Host: GitHub
- URL: https://github.com/pine/spring-cache-interceptors
- Owner: pine
- License: mit
- Created: 2019-06-05T07:32:53.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-11-14T04:55:09.000Z (almost 2 years ago)
- Last Synced: 2024-09-29T00:20:19.874Z (about 1 month ago)
- Topics: java, spring-boot, spring-framework
- Language: Java
- Homepage: https://search.maven.org/artifact/moe.pine/spring-cache-interceptors
- Size: 620 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spring-cache-interceptors
[![build](https://github.com/pine/spring-cache-interceptors/actions/workflows/build.yml/badge.svg)](https://github.com/pine/spring-cache-interceptors/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/pine/spring-cache-interceptors/branch/master/graph/badge.svg)](https://codecov.io/gh/pine/spring-cache-interceptors)
[![Maven Central](https://img.shields.io/maven-central/v/moe.pine/spring-cache-interceptors)](https://search.maven.org/artifact/moe.pine/spring-cache-interceptors):herb: Cache interceptors for SpringFramework
![](images/resized.jpg)
© Pongnathee Kluaythong/123RF.COM
## Requirements
- Java 8 or later
- Spring Framework### Supported Spring Framework versions
|Spring Framework versions|Spring Boot versions|This library version|
|-------------------------|--------------------|--------------------|
|5.3 |2.4, 2.5, 2.6, 2.7 |0.2.1 |
|5.2 |2.2, 2.3 |0.1.3 |## Getting started
The library is published to Maven Central.```gradle
repositories {
mavenCentral()
}depepdencies {
implementation "moe.pine:spring-cache-interceptors:$latestVersion"
}
```## Usage
You can create a new interceptor with Spring Framework as following.```java
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](https://profile.pine.moe)