summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Caching/BaseCacheRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Framework/Caching/BaseCacheRepository.cs')
-rw-r--r--src/SMAPI.Web/Framework/Caching/BaseCacheRepository.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/SMAPI.Web/Framework/Caching/BaseCacheRepository.cs b/src/SMAPI.Web/Framework/Caching/BaseCacheRepository.cs
new file mode 100644
index 00000000..f5354b93
--- /dev/null
+++ b/src/SMAPI.Web/Framework/Caching/BaseCacheRepository.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace StardewModdingAPI.Web.Framework.Caching
+{
+ /// <summary>The base logic for a cache repository.</summary>
+ internal abstract class BaseCacheRepository
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Whether cached data is stale.</summary>
+ /// <param name="lastUpdated">The date when the data was updated.</param>
+ /// <param name="staleMinutes">The age in minutes before data is considered stale.</param>
+ public bool IsStale(DateTimeOffset lastUpdated, int staleMinutes)
+ {
+ return lastUpdated < DateTimeOffset.UtcNow.AddMinutes(-staleMinutes);
+ }
+ }
+}