【发布时间】:2020-07-15 06:32:28
【问题描述】:
我在我的 ASP.Net Core 2.2 API 中使用 IDistributedCache 和 SQL Server。
我注意到过期的记录仍保留在表中。有没有办法从缓存表中删除过期记录?
【问题讨论】:
标签: asp.net-core distributed-caching
我在我的 ASP.Net Core 2.2 API 中使用 IDistributedCache 和 SQL Server。
我注意到过期的记录仍保留在表中。有没有办法从缓存表中删除过期记录?
【问题讨论】:
标签: asp.net-core distributed-caching
SqlServerCache 定期检查已删除的缓存项并将其删除,它使用此 SQL 命令。
DELETE FROM {0} WHERE @UtcNow > ExpiresAtTime
请检查您的 DB 表以获取 ExpiresAtTime 的值。
SqlServerCache 类来源:https://github.com/dotnet/extensions/blob/master/src/Caching/SqlServer/src/SqlServerCache.cs
DatabaseOperations 类的来源,包含DeleteExpiredCacheItems 方法:https://github.com/dotnet/extensions/blob/master/src/Caching/SqlServer/src/DatabaseOperations.cs
【讨论】: