Definition
Assembly: Microsoft.OData.Mcp.Core.dll Namespace: Microsoft.OData.Mcp.Core.Configuration Inheritance: System.ObjectSyntax
Summary
Configuration for metadata and tool caching behavior.Remarks
Caching configuration controls how long metadata and generated tools are cached to improve performance and reduce load on the underlying OData service. This class provides comprehensive caching options including provider selection, TTL settings, size limits, and advanced features like compression and warming.Constructors
.ctor
Initializes a new instance of the CachingConfiguration class.Syntax
.ctor Inherited
Inherited from
objectSyntax
Properties
Compression
Gets or sets the compression configuration for cached data.Syntax
Property Value
Type:Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration
Configuration for compressing cached data to save memory/storage.
Remarks
Cache compression can significantly reduce memory usage for large cached objects at the cost of additional CPU overhead.CustomProperties
Gets or sets custom caching properties.Syntax
Property Value
Type:System.Collections.Generic.Dictionary<string, object>
A dictionary of custom caching configuration values.
Remarks
Custom properties allow extending the configuration with cache provider-specific settings that don’t fit into the standard configuration properties.DistributedCache
Gets or sets the distributed cache configuration.Syntax
Property Value
Type:Microsoft.OData.Mcp.Core.Configuration.DistributedCacheConfiguration
Configuration for distributed caching across multiple server instances.
Remarks
Distributed caching enables cache sharing between multiple MCP server instances for improved consistency and performance.Enabled
Gets or sets a value indicating whether caching is enabled.Syntax
Property Value
Type:bool
true to enable caching; otherwise, false.
Remarks
When caching is disabled, metadata and tools will be regenerated for every request, which can impact performance but ensures the latest data is always used.EnableStatistics
Gets or sets a value indicating whether to enable cache statistics collection.Syntax
Property Value
Type:bool
true to collect cache statistics; otherwise, false.
Remarks
Cache statistics provide insights into cache hit rates, evictions, and performance metrics for monitoring and optimization.EnableWarming
Gets or sets a value indicating whether to enable cache warming.Syntax
Property Value
Type:bool
true to pre-populate the cache on startup; otherwise, false.
Remarks
Cache warming pre-populates frequently accessed data to improve initial response times after server startup.EvictionPolicy
Gets or sets the cache eviction policy.Syntax
Property Value
Type:Microsoft.OData.Mcp.Core.Configuration.CacheEvictionPolicy
The policy used to determine which entries to evict when cache limits are reached.
Remarks
Different eviction policies optimize for different access patterns and performance characteristics.KeyPrefix
Gets or sets the cache key prefix.Syntax
Property Value
Type:string
A prefix added to all cache keys to avoid collisions.
Remarks
Key prefixes are useful when multiple MCP server instances share the same cache infrastructure.MaxEntries
Gets or sets the maximum number of cache entries.Syntax
Property Value
Type:System.Nullable<int>
The maximum number of entries in the cache, or null for no limit.
Remarks
Entry count limits provide an alternative way to control cache size when individual entry sizes vary significantly.MaxSizeMb
Gets or sets the maximum size of the cache in megabytes.Syntax
Property Value
Type:System.Nullable<int>
The maximum cache size in MB, or null for no limit.
Remarks
Cache size limits prevent excessive memory usage. When the limit is reached, older entries will be evicted using the configured eviction policy.MetadataTtl
Gets or sets the Time-To-Live (TTL) for metadata cache entries.Syntax
Property Value
Type:System.TimeSpan
The duration to cache metadata before it expires.
Remarks
Metadata is typically stable and can be cached for longer periods. A shorter TTL ensures faster detection of schema changes.ProviderType
Gets or sets the cache provider type.Syntax
Property Value
Type:Microsoft.OData.Mcp.Core.Configuration.CacheProviderType
The type of cache provider to use.
Remarks
Different cache providers offer different characteristics in terms of persistence, performance, and distributed caching capabilities.QueryResultsTtl
Gets or sets the Time-To-Live (TTL) for query result cache entries.Syntax
Property Value
Type:System.TimeSpan
The duration to cache query results before they expire.
Remarks
Query results represent actual data and should typically have shorter TTL values to ensure data freshness.ToolsTtl
Gets or sets the Time-To-Live (TTL) for generated tools cache entries.Syntax
Property Value
Type:System.TimeSpan
The duration to cache generated tools before they expire.
Remarks
Generated tools are derived from metadata and can be cached separately with different TTL values for performance optimization.WarmingDelay
Gets or sets the cache warming delay after startup.Syntax
Property Value
Type:System.TimeSpan
The delay before starting cache warming operations.
Remarks
A startup delay allows the server to fully initialize before beginning resource-intensive cache warming operations.Methods
Clone
Creates a copy of this configuration.Syntax
Returns
Type:Microsoft.OData.Mcp.Core.Configuration.CachingConfiguration
A new instance with the same settings.
Disabled
Creates a configuration with caching disabled.Syntax
Returns
Type:Microsoft.OData.Mcp.Core.Configuration.CachingConfiguration
A caching configuration with all caching disabled.
Remarks
Disabled caching ensures the freshest data is always retrieved at the cost of performance. Useful for debugging or when data consistency is more important than performance.Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
obj | object? | - |
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
ForDevelopment
Creates a configuration optimized for development environments.Syntax
Returns
Type:Microsoft.OData.Mcp.Core.Configuration.CachingConfiguration
A caching configuration suitable for development.
Remarks
Development configurations use shorter TTLs and smaller cache sizes to ensure faster detection of changes during development cycles.ForProduction
Creates a configuration optimized for production environments.Syntax
Returns
Type:Microsoft.OData.Mcp.Core.Configuration.CachingConfiguration
A caching configuration suitable for production.
Remarks
Production configurations use longer TTLs, larger cache sizes, and enable advanced features like compression and warming for optimal performance.GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetMetadataKey
Gets the cache key for a metadata entry.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
serviceUrl | string | The OData service URL. |
Returns
Type:string
The cache key for the metadata.
Exceptions
| Exception | Description |
|---|---|
ArgumentException | Thrown when serviceUrl is null or whitespace. |
GetQueryResultKey
Gets the cache key for a query result entry.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
serviceUrl | string | The OData service URL. |
queryHash | string | The hash of the query parameters. |
userContext | string? | Optional user context for user-specific caching. |
Returns
Type:string
The cache key for the query result.
Exceptions
| Exception | Description |
|---|---|
ArgumentException | Thrown when serviceUrl is null or whitespace. |
GetToolsKey
Gets the cache key for a tools entry.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
serviceUrl | string | The OData service URL. |
optionsHash | string | The hash of the tool generation options. |
Returns
Type:string
The cache key for the tools.
Exceptions
| Exception | Description |
|---|---|
ArgumentException | Thrown when serviceUrl is null or whitespace. |
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
MergeWith
Merges another configuration into this one, with the other configuration taking precedence.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
other | Microsoft.OData.Mcp.Core.Configuration.CachingConfiguration | The configuration to merge into this one. |
Exceptions
| Exception | Description |
|---|---|
ArgumentNullException | Thrown when other is null. |
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Validate
Validates the caching configuration.Syntax
Returns
Type:System.Collections.Generic.IEnumerable<string>
A collection of validation errors, or empty if the configuration is valid.