mcp_registry_client.cache
Response caching for the MCP registry client.
CacheEntry
Cache entry with expiration support.
Source code in mcp_registry_client/cache.py
__init__(value, ttl)
Initialize cache entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
T
|
The cached value |
required |
ttl
|
int
|
Time to live in seconds |
required |
ResponseCache
In-memory response cache with TTL support.
Source code in mcp_registry_client/cache.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
__init__(config)
Initialize response cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ClientConfig
|
Client configuration with cache settings |
required |
Source code in mcp_registry_client/cache.py
cache_key_for_search(name)
Generate cache key for search requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Search name parameter |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cache key |
cache_key_for_server(server_id)
Generate cache key for server requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_id
|
str
|
Server ID |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cache key |
cache_key_for_server_by_name(name)
Generate cache key for server by name requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Server name |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cache key |
cleanup_expired()
async
Remove expired entries from the cache.
Source code in mcp_registry_client/cache.py
clear()
async
get(key)
async
Get a value from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Cache key |
required |
Returns:
| Type | Description |
|---|---|
Any | None
|
Cached value if found and not expired, None otherwise |
Source code in mcp_registry_client/cache.py
set(key, value)
async
Set a value in the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Cache key |
required |
value
|
Any
|
Value to cache |
required |