spring-cache-interceptors

Cache interceptors for SpringFramework

License

License

GroupId

GroupId

moe.pine
ArtifactId

ArtifactId

spring-cache-interceptors
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

spring-cache-interceptors
Cache interceptors for SpringFramework
Project URL

Project URL

https://github.com/pine/spring-cache-interceptors
Source Code Management

Source Code Management

https://github.com/pine/spring-cache-interceptors

Download spring-cache-interceptors

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

spring-cache-interceptors

Build Status codecov Maven Central

🍃 Cache interceptors for SpringFramework


© 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

Versions

Version
0.2.0
0.1.3