Skip to main content

Definition

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

Syntax

Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration

Summary

Configuration for cache compression.

Remarks

Cache compression configuration controls how cached data is compressed to reduce memory usage and storage requirements. Compression can significantly reduce cache size at the cost of additional CPU overhead during cache operations.

Constructors

.ctor

Initializes a new instance of the CacheCompressionConfiguration class.

Syntax

public CacheCompressionConfiguration()

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

Algorithm

Gets or sets the compression algorithm to use.

Syntax

public string Algorithm { get; set; }

Property Value

Type: string The name of the compression algorithm.

Examples

Common values:
  • “gzip”: Good balance of compression and speed
  • “deflate”: Similar to gzip but with less overhead
  • “brotli”: Better compression ratio but slower

Remarks

Supported algorithms typically include “gzip”, “deflate”, and “brotli”. Different algorithms offer different trade-offs between compression ratio, speed, and CPU usage.

CompressionLevel

Gets or sets the compression level.

Syntax

public int CompressionLevel { get; set; }

Property Value

Type: int The compression level from 0 (no compression) to 9 (maximum compression).

Remarks

Higher compression levels provide better compression ratios but require more CPU time. Level 6 typically provides a good balance between compression ratio and performance.

Enabled

Gets or sets a value indicating whether cache compression is enabled.

Syntax

public bool Enabled { get; set; }

Property Value

Type: bool true to enable compression; otherwise, false.

Remarks

When compression is enabled, cached data will be compressed before storage and decompressed when retrieved. This can significantly reduce memory usage for large cached objects.

MinimumSize

Gets or sets the minimum size in bytes before compression is applied.

Syntax

public int MinimumSize { get; set; }

Property Value

Type: int The minimum size threshold for compression.

Remarks

Small objects may not benefit from compression due to the overhead of the compression algorithm. Objects smaller than this threshold will be stored uncompressed.

Methods

Clone

Creates a copy of this configuration.

Syntax

public Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration Clone()

Returns

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

Disabled

Creates a configuration with compression disabled.

Syntax

public static Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration Disabled()

Returns

Type: Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration A compression configuration with compression disabled.

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

FastCompression

Creates a configuration optimized for fast compression.

Syntax

public static Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration FastCompression()

Returns

Type: Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration A compression configuration optimized for speed.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MaximumCompression

Creates a configuration optimized for maximum compression.

Syntax

public static Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration MaximumCompression()

Returns

Type: Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration A compression configuration optimized for compression ratio.

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

MergeWith

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

Syntax

public void MergeWith(Microsoft.OData.Mcp.Core.Configuration.CacheCompressionConfiguration other)

Parameters

NameTypeDescription
otherMicrosoft.OData.Mcp.Core.Configuration.CacheCompressionConfigurationThe configuration to merge into this one.

Remarks

All values from the other configuration will override values in this configuration. This allows for complete updates of compression settings.

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

Validate

Validates the compression configuration.

Syntax

public System.Collections.Generic.IEnumerable<string> Validate()

Returns

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