ユーザーの有効なライセンスを保持するクラスがあり、現在のライセンスが有効であることを確認したり、変更された可能性のあるものを追加または削除するために15分ごとに「検証」されます。MVC2でのキャッシュストレージの使用
現在のところ、これはアプリケーション内の他のすべてのコントローラが継承する私のApplicationControllerでアクセスされるため、ユーザが操作を実行するたびに有効なライセンス/権限があることが保証されます。
ライセンスモデル:
public class LicenseModel
{
public DateTime LastValidated { get; set; }
public List<License> ValidLicenses { get; set; }
public bool NeedsValidation
{
get{ return ((DateTime.Now - this.LastValidated).Minutes >= 15);}
}
//Constructor etc...
}
検証プロセス:(ApplicationControllerにの初期化()メソッドの内部で起こる)
LicenseModel licenseInformation = new LicenseModel();
if (Session["License"] != null)
{
licenseInformation = Session["License"] as LicenseModel;
if (licenseInformation.NeedsValidation)
licenseInformation.ValidLicenses = Service.GetLicenses();
licenseInformation.LastValidated = DateTime.Now;
Session["License"] = licenseInformation;
}
else
{
licenseInformation = new LicenseModel(Service.GetLicenses());
Session["License"] = licenseInformation;
}
概要:
ご覧のとおり、このプロセスでは現在セッションを使用してLicenseModelを保存していますが、キャッシュを使用してこれを保存する方が簡単か効率が良いかどうかは疑問でした。 (あるいは、おそらくOutputCache?)と私はそれをどうやって実装しようとしますか?