NetCoreCacheService.dll
public IActionResult Index () { // stored string MemoryCacheService.SetChacheValue ( " sname " , " Liuqi Qi " ); // get the string buffer ViewBag.sbname = MemoryCacheService.GetCacheValue ( " sname " ); // stored generic list list <TsetModel> list = new new list <TsetModel> (); for ( int I = 0 ; I < 100 ; I ++ ) { TsetModel Model =new TsetModel(); model.Id = i; model.Name = "刘奇" + i; list.Add(model); } MemoryCacheService.SetChacheValue("ulist", list); //获取list缓存 var newList = MemoryCacheService.GetList<TsetModel>("ulist"); return View(newList); } public IActionResult About() { M TsetModel = new new TsetModel (); m.Id = 100 ; m.Name = " Liu " ; // stored Model MemoryCacheService.SetChacheValue ( " UM " , m); // Get Model return View (MemoryCacheService.Get < TsetModel> ( " UM " )); }
public class TsetModel { public int Id { get; set; } public string Name { get; set; } }