Class CachingOperationInvoker
- java.lang.Object
- org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker
- All Implemented Interfaces:
OperationInvoker
public class CachingOperationInvoker extends Object implements OperationInvoker
AnOperationInvoker
that caches the response of an operation with a configurable time to live.- Since:
- 2.0.0
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OperationInvoker
apply(OperationInvoker invoker, long timeToLive)
Apply caching configuration when appropriate to the given invoker.long
getTimeToLive()
Return the maximum time in milliseconds that a response can be cached.Object
invoke(InvocationContext context)
Invoke the underlying operation using the givencontext
.
Method Detail
getTimeToLive
public long getTimeToLive()
Return the maximum time in milliseconds that a response can be cached.- Returns:
- the time to live of a response
invoke
public Object invoke(InvocationContext context)
Description copied from interface:OperationInvoker
Invoke the underlying operation using the givencontext
.- Specified by:
invoke
in interfaceOperationInvoker
- Parameters:
context
- the context to use to invoke the operation- Returns:
- the result of the operation, may be
null
apply
public static OperationInvoker apply(OperationInvoker invoker, long timeToLive)
Apply caching configuration when appropriate to the given invoker.- Parameters:
invoker
- the invoker to wraptimeToLive
- the maximum time in milliseconds that a response can be cached- Returns:
- a caching version of the invoker or the original instance if caching is not required