Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/InMemoryStorageOptions.cs
T
Reuben Bond 33f84f9ed2 .NET: Improve fidelity of OpenAI Responses server and add Conversations (#1907)
* Improve fidelity of OpenAI Responses server and add Conversations

* Merge

* nit

* Undo prior change

* Undo prior change

* Review feedback

* Review feedback

* Fix test

* Use simpler JsonDocument approach for polymorphic deserialization

* More review feedback

* dotnet format
2025-11-05 18:46:19 +00:00

51 lines
1.6 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System;
using Microsoft.Extensions.Caching.Memory;
namespace Microsoft.Agents.AI.Hosting.OpenAI;
/// <summary>
/// Configuration options for in-memory storage implementations.
/// </summary>
internal sealed class InMemoryStorageOptions
{
/// <summary>
/// Gets or sets the maximum number of items to store in the cache.
/// Default is 1000. Set to null for no size limit.
/// </summary>
public long? SizeLimit { get; set; } = 1000;
/// <summary>
/// Gets or sets the absolute expiration time for items in storage.
/// If specified, items will be expired after this timespan regardless of access.
/// Default is null (no absolute expiration).
/// </summary>
public TimeSpan? AbsoluteExpirationRelativeToNow { get; set; }
/// <summary>
/// Gets or sets the sliding expiration for items in storage.
/// Items will be expired if not accessed within this timespan.
/// Default is 1 hour.
/// </summary>
public TimeSpan? SlidingExpiration { get; set; } = TimeSpan.FromHours(1);
/// <summary>
/// Creates <see cref="MemoryCacheOptions"/> from these options.
/// </summary>
internal MemoryCacheOptions ToMemoryCacheOptions() => new()
{
SizeLimit = this.SizeLimit
};
/// <summary>
/// Creates <see cref="MemoryCacheEntryOptions"/> from these options.
/// </summary>
internal MemoryCacheEntryOptions ToMemoryCacheEntryOptions() => new()
{
AbsoluteExpirationRelativeToNow = this.AbsoluteExpirationRelativeToNow,
SlidingExpiration = this.SlidingExpiration,
Size = 1
};
}