JVM library for server-side HTTP-cache validation boosting. KCache adds caching layer for ETag HTTP header in Spring Boot powered applications.
Maven/Gradle import instructions
@GetMapping("/workers/{workerId}/area")
@KCacheable(
resources = ["workers", "areas"],
// optional
keys = ["#args[0]"],
// optional
resultBuilder = ResponseEntityKCacheResultBuilder::class
)
fun getWorkerAreaById(
@PathVariable workerId: Int
): ResponseEntity<Area> {
return ResponseEntity.ok(
// business logic
workerService.getWorkerAreaById(workerId)
)
}
@KCacheEvict(
resources = ["workers"],
// optional
keys = ["#args[0].id"],
)
fun updateWorker(worker: Worker){
workersRepository.update(worker)
}
Framework configuration is available via Spring application.(yaml|properties), e.g.:
kcache:
jpa:
listener:
enable: true
state-storage:
# also supports RAM and redis storages
name: hazelcast
hazelcast:
discovery:
type: TCP_IP
tcp-ip:
members: localhost
redis:
host: localhost
port: 6379
aop:
# also supports AspectJ
type: spring-aop