HTTPCacheOptions.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. namespace Best.HTTP.Caching
  3. {
  4. /// <summary>
  5. /// Represents the configuration options for the HTTP cache.
  6. /// </summary>
  7. public sealed class HTTPCacheOptions
  8. {
  9. /// <summary>
  10. /// Gets or sets the maximum duration for which cached entries will be retained.
  11. /// </summary>
  12. public TimeSpan DeleteOlder { get; internal set; } = TimeSpan.MaxValue;
  13. /// <summary>
  14. /// Gets or sets the maximum size, in bytes, that the cache can reach.
  15. /// </summary>
  16. public ulong MaxCacheSize { get; internal set; } = 512 * 1024 * 1024;
  17. /// <summary>
  18. /// Initializes a new instance of the <see cref="HTTPCacheOptions"/> class with default settings.
  19. /// </summary>
  20. public HTTPCacheOptions()
  21. {
  22. // Default constructor with no arguments.
  23. }
  24. /// <summary>
  25. /// Initializes a new instance of the <see cref="HTTPCacheOptions"/> class with custom settings.
  26. /// </summary>
  27. /// <param name="deleteOlder">The maximum age for cached entries to be retained.</param>
  28. /// <param name="maxCacheSize">The maximum size, in bytes, that the cache can reach.</param>
  29. public HTTPCacheOptions(TimeSpan deleteOlder, ulong maxCacheSize)
  30. {
  31. this.DeleteOlder = deleteOlder;
  32. this.MaxCacheSize = maxCacheSize;
  33. }
  34. }
  35. }