I have read the article: link
And I started using the:
[OutputCache(Duration = 60, VaryByParam = "none")]
When I put it in the controller I notice the difference clearly.
But when I'm using a library that is called by my controller , it does not seem to be the case.
The code is as follows:
[OutputCache(Duration = 60, Location = OutputCacheLocation.ServerAndClient, VaryByParam = "none")]
internal IEnumerable<CPUStats> ProcessarStatsSQL()
{
var DateQuery = db.servidorSQL.ToList().Select(o => new CPUStats
{
Data = DateTime.Parse(o.Data, new CultureInfo("en-US")),
CPU = Double.Parse(o.CPU,new CultureInfo("en-US")),
RAM = Double.Parse(o.RAM, new CultureInfo("en-US")),
Disco = Double.Parse(o.Disco, new CultureInfo("en-US"))
});
return DateQuery;
}
[OutputCache(Duration = 60, VaryByParam = "none")]
public DateTime Data_SQL()
{
var DateQuery = ProcessarStatsSQL();
var Data = DateQuery.OrderByDescending(x => x.Data).Take(1).ToList();
return (DateTime)Data.FirstOrDefault().Data;
}
[OutputCache(Duration = 60, VaryByParam = "none")]
public Double IO_SQL()
{
var DateQuery = ProcessarStatsSQL();
var IO = DateQuery.OrderByDescending(x => x.Data).Take(5).ToList();
return (double)IO.Average(a => a.Disco);
}
Is the IO_SQL()
and Data_SQL()
should not use the cache already done previously?
But in debug I see that it processes the query in the DataBase for each IO_SQL()
and Data_SQL()
Can I use an HtmlHelper?
[OutputCache(Duration = 60, VaryByParam = "none")]
public static IHtmlString VerificaRAM(this HtmlHelper helper)