【问题标题】:IDistributedCache SQL Server delete expired recordsIDistributedCache SQL Server 删除过期记录
【发布时间】:2020-07-15 06:32:28
【问题描述】:

我在我的 ASP.Net Core 2.2 API 中使用 IDistributedCache 和 SQL Server。

我注意到过期的记录仍保留在表中。有没有办法从缓存表中删除过期记录?

【问题讨论】:

    标签: asp.net-core distributed-caching


    【解决方案1】:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 1970-01-01
      • 1970-01-01
      • 2011-03-20
      • 1970-01-01
      • 1970-01-01
      • 2018-12-01
      相关资源
      最近更新 更多