Class AgentInvocationCacheImpl<H extends AiAgentFilter>
java.lang.Object
com.aispect.core.engine.bootstrap.registry.AgentInvocationCacheImpl<H>
- Type Parameters:
H- Inherited fromAiAgentFilterfilter type
- All Implemented Interfaces:
AgentInvocationCache<H>
public class AgentInvocationCacheImpl<H extends AiAgentFilter>
extends Object
implements AgentInvocationCache<H>
The default implementation class for proxy call caching.
belongstartup phase (Bootstrap)core registry.
When the application starts, it is AiComponentScanner Scan for annotations on the target interface,
Will be instantiated after verification AiAgentFilter Resources are stored in this table, and the creation method is the same as Handler mapping relationship.
ConcurrentHashMap To ensure thread-safe cache access operations.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all data in cache.computeHash(Method method, AiExecutePhase phase) Computes a cache's unique hash value (key) based on method and execution phase.get(Method method, AiExecutePhase phase) Gets the filter resource for the specified method and stage from the cache.voidput(Method method, AiExecutePhase phase, H resource) Put the filter resource into cache. If the same key already exists in the cache, an exception will be thrown to prevent overwriting.booleanremove(Method method, AiExecutePhase phase) Removes the filter resource for the specified method and stage from the cache.
-
Constructor Details
-
AgentInvocationCacheImpl
public AgentInvocationCacheImpl()
-
-
Method Details
-
computeHash
Computes a cache's unique hash value (key) based on method and execution phase.- Specified by:
computeHashin interfaceAgentInvocationCache<H extends AiAgentFilter>- Parameters:
method- target methodphase- AI Execution phase- Returns:
- The format is "Stage name@method name" hash string
-
put
Put the filter resource into cache. If the same key already exists in the cache, an exception will be thrown to prevent overwriting.- Specified by:
putin interfaceAgentInvocationCache<H extends AiAgentFilter>- Parameters:
method- target methodphase- AI Execution phaseresource- Filter resource to cache- Throws:
AiSpectException- This exception is thrown if the cache for this method and stage already exists
-
get
Gets the filter resource for the specified method and stage from the cache.- Specified by:
getin interfaceAgentInvocationCache<H extends AiAgentFilter>- Parameters:
method- target methodphase- AI Execution phase- Returns:
- The cached filter resource, returned if it does not exist null
-
remove
Removes the filter resource for the specified method and stage from the cache.- Specified by:
removein interfaceAgentInvocationCache<H extends AiAgentFilter>- Parameters:
method- target methodphase- AI Execution phase- Returns:
- If removed successfully return true,If it does not exist in the cache, return false
-
clear
public void clear()Clear all data in cache.- Specified by:
clearin interfaceAgentInvocationCache<H extends AiAgentFilter>
-