summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Framework')
-rw-r--r--src/SMAPI.Web/Framework/Caching/Mods/IModCacheRepository.cs5
-rw-r--r--src/SMAPI.Web/Framework/Caching/Mods/ModCacheRepository.cs8
2 files changed, 13 insertions, 0 deletions
diff --git a/src/SMAPI.Web/Framework/Caching/Mods/IModCacheRepository.cs b/src/SMAPI.Web/Framework/Caching/Mods/IModCacheRepository.cs
index 23929d1d..bcec8b36 100644
--- a/src/SMAPI.Web/Framework/Caching/Mods/IModCacheRepository.cs
+++ b/src/SMAPI.Web/Framework/Caching/Mods/IModCacheRepository.cs
@@ -1,3 +1,4 @@
+using System;
using StardewModdingAPI.Toolkit.Framework.UpdateData;
using StardewModdingAPI.Web.Framework.ModRepositories;
@@ -22,5 +23,9 @@ namespace StardewModdingAPI.Web.Framework.Caching.Mods
/// <param name="mod">The mod data.</param>
/// <param name="cachedMod">The stored mod record.</param>
void SaveMod(ModRepositoryKey site, string id, ModInfoModel mod, out CachedMod cachedMod);
+
+ /// <summary>Delete data for mods which haven't been requested within a given time limit.</summary>
+ /// <param name="age">The minimum age for which to remove mods.</param>
+ void RemoveStaleMods(TimeSpan age);
}
}
diff --git a/src/SMAPI.Web/Framework/Caching/Mods/ModCacheRepository.cs b/src/SMAPI.Web/Framework/Caching/Mods/ModCacheRepository.cs
index d8ad7d21..4258cc85 100644
--- a/src/SMAPI.Web/Framework/Caching/Mods/ModCacheRepository.cs
+++ b/src/SMAPI.Web/Framework/Caching/Mods/ModCacheRepository.cs
@@ -67,6 +67,14 @@ namespace StardewModdingAPI.Web.Framework.Caching.Mods
cachedMod = this.SaveMod(new CachedMod(site, id, mod));
}
+ /// <summary>Delete data for mods which haven't been requested within a given time limit.</summary>
+ /// <param name="age">The minimum age for which to remove mods.</param>
+ public void RemoveStaleMods(TimeSpan age)
+ {
+ DateTimeOffset minDate = DateTimeOffset.UtcNow.Subtract(age);
+ var result = this.Mods.DeleteMany(p => p.LastRequested < minDate);
+ }
+
/*********
** Private methods