CachedDiscoverer
in package
Cached decorator for the Discoverer class.
This decorator caches the results of file system operations and reflection to improve performance when discovery is called multiple times.
Tags
Table of Contents
Constants
- CACHE_PREFIX = 'mcp_discovery_'
Properties
- $cache : CacheInterface
- $discoverer : Discoverer
- $logger : LoggerInterface
Methods
- __construct() : mixed
- clearCache() : void
- Clear the discovery cache.
- discover() : DiscoveryState
- Discover MCP elements in the specified directories with caching.
- generateCacheKey() : string
- Generate a cache key based on discovery parameters.
Constants
CACHE_PREFIX
private
mixed
CACHE_PREFIX
= 'mcp_discovery_'
Properties
$cache read-only
private
CacheInterface
$cache
$discoverer read-only
private
Discoverer
$discoverer
$logger read-only
private
LoggerInterface
$logger
Methods
__construct()
public
__construct(Discoverer $discoverer, CacheInterface $cache, LoggerInterface $logger) : mixed
Parameters
- $discoverer : Discoverer
- $cache : CacheInterface
- $logger : LoggerInterface
clearCache()
Clear the discovery cache.
public
clearCache() : void
Useful for development or when files change.
discover()
Discover MCP elements in the specified directories with caching.
public
discover(string $basePath, array<string|int, string> $directories[, array<string|int, string> $excludeDirs = [] ]) : DiscoveryState
Parameters
- $basePath : string
-
the base path for resolving directories
- $directories : array<string|int, string>
-
list of directories (relative to base path) to scan
- $excludeDirs : array<string|int, string> = []
-
list of directories (relative to base path) to exclude from the scan
Return values
DiscoveryStategenerateCacheKey()
Generate a cache key based on discovery parameters.
private
generateCacheKey(string $basePath, array<string|int, string> $directories, array<string|int, string> $excludeDirs) : string
Parameters
- $basePath : string
- $directories : array<string|int, string>
- $excludeDirs : array<string|int, string>