java.lang.Object
org.miaixz.bus.limiter.metric.MethodProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Provider,Provider
Implements the
Provider interface for handling the HOT_METHOD strategy mode. This provider is responsible for
caching method invocation results for a specified duration to optimize performance for frequently accessed methods
(hot methods).- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newMethodProviderand initializes the timed cache. -
Method Summary
Modifier and TypeMethodDescriptionget()Returns the strategy mode supported by this provider, which isStrategyMode.HOT_METHOD.Processes the method invocation by first checking if the result is available in the cache.
-
Constructor Details
-
MethodProvider
public MethodProvider()Constructs a newMethodProviderand initializes the timed cache. The cache's time-to-live (TTL) is determined by thesecondsproperty loaded from the globalHoldercontext. A pruning schedule is also set up to clean expired entries.
-
-
Method Details
-
get
Returns the strategy mode supported by this provider, which isStrategyMode.HOT_METHOD.- Specified by:
getin interfaceProvider- Returns:
- The
StrategyMode.HOT_METHODenum value.
-
process
Processes the method invocation by first checking if the result is available in the cache. If the result is cached and not expired, it is returned directly. Otherwise, the method is invoked, its result is stored in the cache, and then returned.
-