summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Caching/Cached.cs
blob: b393e1e1dd116fc12ae6dbd76628c7397cd6492f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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; }

        /// <summary>When the data was last updated.</summary>
        public DateTimeOffset LastUpdated { get; }

        /// <summary>When the data was last requested through the mod API.</summary>
        public DateTimeOffset LastRequested { get; internal set; }


        /*********
        ** Public methods
        *********/
        /// <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;
        }
    }
}