diff options
Diffstat (limited to 'src/SMAPI.Web/Framework/Caching/Cached.cs')
-rw-r--r-- | src/SMAPI.Web/Framework/Caching/Cached.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/SMAPI.Web/Framework/Caching/Cached.cs b/src/SMAPI.Web/Framework/Caching/Cached.cs new file mode 100644 index 00000000..52041a16 --- /dev/null +++ b/src/SMAPI.Web/Framework/Caching/Cached.cs @@ -0,0 +1,37 @@ +using System; + +namespace StardewModdingAPI.Web.Framework.Caching +{ + /// <summary>A cache entry.</summary> + /// <typeparam name="T">The cached value type.</typeparam> + internal class Cached<T> + { + /********* + ** Accessors + *********/ + /// <summary>The cached data.</summary> + public T Data { get; set; } + + /// <summary>When the data was last updated.</summary> + public DateTimeOffset LastUpdated { get; set; } + + /// <summary>When the data was last requested through the mod API.</summary> + public DateTimeOffset LastRequested { get; set; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an empty instance.</summary> + public Cached() { } + + /// <summary>Construct an instance.</summary> + /// <param name="data">The cached data.</param> + public Cached(T data) + { + this.Data = data; + this.LastUpdated = DateTimeOffset.UtcNow; + this.LastRequested = DateTimeOffset.UtcNow; + } + } +} |