summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Caching/BaseCacheRepository.cs
blob: f5354b9398a38f1e49b7bae3cdb584aa6b6bed5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);
        }
    }
}