{"record":{"id":"135d7292c4c2a03d","repo":"dotnet/aspnetcore","slug":"expireditemsdeletioninterval-cannot-be-less-than-t","errorCode":null,"errorMessage":"ExpiredItemsDeletionInterval cannot be less than the minimum value of {0} minutes.","messagePattern":"ExpiredItemsDeletionInterval cannot be less than the minimum value of (.+?) minutes\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Caching/SqlServer/src/SqlServerCache.cs","lineNumber":47,"sourceCode":"    private readonly TimeSpan _defaultSlidingExpiration;\n    private readonly Object _mutex = new Object();\n\n    /// <summary>\n    /// Initializes a new instance of <see cref=\"SqlServerCache\"/>.\n    /// </summary>\n    /// <param name=\"options\">The configuration options.</param>\n    public SqlServerCache(IOptions<SqlServerCacheOptions> options)\n    {\n        var cacheOptions = options.Value;\n\n        ArgumentThrowHelper.ThrowIfNullOrEmpty(cacheOptions.ConnectionString);\n        ArgumentThrowHelper.ThrowIfNullOrEmpty(cacheOptions.SchemaName);\n        ArgumentThrowHelper.ThrowIfNullOrEmpty(cacheOptions.TableName);\n\n        if (cacheOptions.ExpiredItemsDeletionInterval.HasValue &&\n            cacheOptions.ExpiredItemsDeletionInterval.Value < MinimumExpiredItemsDeletionInterval)\n        {\n            throw new ArgumentException(\n                $\"{nameof(SqlServerCacheOptions.ExpiredItemsDeletionInterval)} cannot be less than the minimum \" +\n                $\"value of {MinimumExpiredItemsDeletionInterval.TotalMinutes} minutes.\");\n        }\n        if (cacheOptions.DefaultSlidingExpiration <= TimeSpan.Zero)\n        {\n#pragma warning disable CA2208 // Instantiate argument exceptions correctly\n            throw new ArgumentOutOfRangeException(\n                nameof(cacheOptions.DefaultSlidingExpiration),\n                cacheOptions.DefaultSlidingExpiration,\n                \"The sliding expiration value must be positive.\");\n#pragma warning restore CA2208 // Instantiate argument exceptions correctly\n        }\n\n        _systemClock = cacheOptions.SystemClock ?? new SystemClock();\n        _expiredItemsDeletionInterval =\n            cacheOptions.ExpiredItemsDeletionInterval ?? DefaultExpiredItemsDeletionInterval;\n        _deleteExpiredCachedItemsDelegate = DeleteExpiredCacheItems;\n        _defaultSlidingExpiration = cacheOptions.DefaultSlidingExpiration;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Caching/SqlServer/src/SqlServerCache.cs#L29-L65","documentation":"Thrown in the SqlServerCache constructor when ExpiredItemsDeletionInterval is set but is below the minimum allowed interval (MinimumExpiredItemsDeletionInterval). The interval controls how often a background sweep deletes expired rows; too small a value would cause excessive database load.","triggerScenarios":"Constructing/configuring SqlServerCache with options.ExpiredItemsDeletionInterval having a value but less than MinimumExpiredItemsDeletionInterval (the message reports the threshold in minutes).","commonSituations":"Setting the interval to a few seconds intending 'aggressive cleanup'; misreading the option as milliseconds instead of a TimeSpan; copying a config value from another cache provider with different semantics.","solutions":["Set ExpiredItemsDeletionInterval to a TimeSpan >= MinimumExpiredItemsDeletionInterval (the value named in the message).","If you don't need a custom interval, omit the option to use the default (DefaultExpiredItemsDeletionInterval).","Double-check that the value is a TimeSpan and units are correct (minutes, not seconds)."],"exampleFix":"// before: too small\nservices.AddDistributedSqlServerCache(o => { o.ExpiredItemsDeletionInterval = TimeSpan.FromSeconds(10); ... });\n\n// after: at or above the minimum (default is 30 minutes)\nservices.AddDistributedSqlServerCache(o => { o.ExpiredItemsDeletionInterval = TimeSpan.FromMinutes(30); ... });","handlingStrategy":"validation","validationCode":"if (options.ExpiredItemsDeletionInterval.HasValue && options.ExpiredItemsDeletionInterval.Value < SqlServerCache.MinimumExpiredItemsDeletionInterval) { /* raise or omit option */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the option as a TimeSpan in minutes, not seconds/ms.","Omit the option to use the documented default.","Validate cache options at startup with ValidateOnStart()."],"tags":["caching","sqlserver","aspnetcore","distributed-cache","configuration"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}