namespace NpgsqlRest;
public class CacheOptions
{
///
/// Default routine cache object. Inject custom cache object to override default cache. Set to null to disable caching.
///
public IRoutineCache? DefaultRoutineCache { get; set; } = new RoutineCache();
///
/// When cache is enabled, this value sets the interval in minutes for cache pruning (removing expired entries). Default is 1 minute.
///
public int MemoryCachePruneIntervalSeconds { get; set; } = 60;
///
/// Maximum number of rows that can be cached for set-returning functions.
/// If a result set exceeds this limit, it will not be cached (but will still be returned).
/// Set to 0 to disable caching for sets entirely. Set to null for unlimited (use with caution).
/// Default is 1000 rows.
///
public int? MaxCacheableRows { get; set; } = 1000;
///
/// When true, cache keys longer than HashKeyThreshold characters are hashed to a fixed-length SHA256 string.
/// This reduces memory usage for long cache keys and improves Redis performance with large keys.
/// Default is false (cache keys are stored as-is).
///
public bool UseHashedCacheKeys { get; set; } = false;
///
/// Cache keys longer than this threshold (in characters) will be hashed when UseHashedCacheKeys is true.
/// Keys shorter than this threshold are stored as-is for better debuggability.
/// Default is 256 characters.
///
public int HashKeyThreshold { get; set; } = 256;
///
/// When set, creates an additional invalidation endpoint for each cached endpoint.
/// The invalidation endpoint has the same path with this suffix appended.
/// For example, if a cached endpoint is /api/my-endpoint/ and this is set to "invalidate",
/// an invalidation endpoint /api/my-endpoint/invalidate will be created.
/// Calling the invalidation endpoint with the same parameters removes the cached entry.
/// Invalidation routes through the endpoint's resolved cache (profile or root).
/// Default is null (no invalidation endpoints created).
///
public string? InvalidateCacheSuffix { get; set; } = null;
///
/// Optional named caching profiles. An endpoint opts into a profile via the @cache_profile <name>
/// comment annotation; that endpoint then uses the profile's instance and
/// inherits the profile's , , and
/// defaults.
///
/// Endpoints without @cache_profile continue to use .
///
/// Unknown profile names referenced by endpoints cause startup to fail (collected and reported as a single
/// error listing every unresolved name and the offending endpoints).
///
/// Cache key prefix: entries written under a profile are prefixed with the profile name to prevent collisions
/// when two profiles share the same backend (e.g., two Memory profiles). Entries written under the default
/// (root) cache have no prefix and are wire-compatible with prior versions.
///
public Dictionary? Profiles { get; set; }
}