49 lines
972 B
C#
49 lines
972 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
|
|
|
|
namespace ServerBase;
|
|
|
|
public abstract class CacheBase
|
|
{
|
|
public DateTime CreatedDateTime { get; set; }
|
|
public DateTime UpdatedDateTime { get; set; }
|
|
public DateTime ExpireDateTime { get; set; }
|
|
|
|
public CacheBase()
|
|
{
|
|
applyUpdatedDateTime();
|
|
}
|
|
|
|
protected void applyCreatedDateTime()
|
|
{
|
|
CreatedDateTime = DateTimeHelper.Current;
|
|
applyUpdatedDateTime();
|
|
}
|
|
|
|
protected void applyExpireDateTime(TimeSpan elapsedTime)
|
|
{
|
|
ExpireDateTime = DateTimeHelper.Current + elapsedTime;
|
|
applyUpdatedDateTime();
|
|
}
|
|
|
|
protected void applyUpdatedDateTime()
|
|
{
|
|
UpdatedDateTime = DateTimeHelper.Current;
|
|
}
|
|
|
|
public string toJsonString()
|
|
{
|
|
return $"{JsonConvert.SerializeObject(this)}";
|
|
}
|
|
}
|