Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Core.dll Namespace: Microsoft.OData.Mcp.Core.Configuration Inheritance: System.Object

Syntax

Summary

Configuration for distributed caching.

Remarks

Distributed cache configuration specifies how the MCP server connects to and uses distributed caching services like Redis or SQL Server for sharing cache data across multiple instances.

Constructors

.ctor

Initializes a new instance of the DistributedCacheConfiguration class.

Syntax

.ctor Inherited

Inherited from object

Syntax

Properties

ConnectionString

Gets or sets the connection string for the distributed cache.

Syntax

Property Value

Type: string? The connection string used to connect to the distributed cache service.

Examples

For Redis: “localhost:6379” For SQL Server: “Server=(localdb)\mssqllocaldb;Database=DistCache;Trusted_Connection=true;“

Remarks

The format of the connection string depends on the cache provider type. For Redis, this would be a Redis connection string. For SQL Server, this would be a SQL Server connection string.

DefaultAbsoluteExpiration

Gets or sets the default absolute expiration for distributed cache entries.

Syntax

Property Value

Type: System.Nullable<System.TimeSpan?>? The maximum time span that cache entries remain valid regardless of access.

Remarks

Absolute expiration ensures that entries are removed from the cache after a fixed period, regardless of how frequently they are accessed. This is useful for ensuring data freshness.

DefaultSlidingExpiration

Gets or sets the default sliding expiration for distributed cache entries.

Syntax

Property Value

Type: System.Nullable<System.TimeSpan?>? The time span that cache entries remain valid after their last access.

Remarks

Sliding expiration resets the expiration time each time an entry is accessed, keeping frequently used items in the cache longer. If not specified, entries will use absolute expiration only.

InstanceName

Gets or sets the instance name for the distributed cache.

Syntax

Property Value

Type: string? A unique name identifying this cache instance.

Remarks

The instance name is used to create unique cache keys and separate cache data between different applications or environments sharing the same distributed cache infrastructure.

Methods

Clone

Creates a copy of this configuration.

Syntax

Returns

Type: Microsoft.OData.Mcp.Core.Configuration.DistributedCacheConfiguration A new instance with the same settings.

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ForRedis

Creates a configuration for Redis distributed caching.

Syntax

Parameters

Returns

Type: Microsoft.OData.Mcp.Core.Configuration.DistributedCacheConfiguration A distributed cache configuration for Redis.

ForSqlServer

Creates a configuration for SQL Server distributed caching.

Syntax

Parameters

Returns

Type: Microsoft.OData.Mcp.Core.Configuration.DistributedCacheConfiguration A distributed cache configuration for SQL Server.

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

MergeWith

Merges another configuration into this one, with the other configuration taking precedence.

Syntax

Parameters

Remarks

Only non-null and non-empty values from the other configuration will override values in this configuration. This allows for partial updates without losing existing settings.

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?

Validate

Validates the distributed cache configuration.

Syntax

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of validation errors, or empty if the configuration is valid.