c# - Asp.net MVC real time application performance -
i'm trying create asp.net mvc web application ,some pages need show data in "real time" ,this data on sql server database ,the data changing created stored procedure in sql server , call procedure in controller using entity framework linq , send result browser using ajax used outputcashing minimize number of execution of stored procedure , in same controller there multiple methode use same stored procedure ,every methode execute same procedure , how emprove performance of application , there way execute stored procedure 1 time controller ??
this controller objective minimize use of database
[outputcache(duration = 20, varybyparam = "*")] public class jobsetlcontroller : controller { private etl_rep_mauientities db = new etl_rep_mauientities(); public objectresult<biogetetljobs_result> etljobs; public jobsetlcontroller() { etljobs =db.biogetetljobs(); } public actionresult indexp() { var y = xx in etljobs xx.etat!="completed" orderby xx.etat ascending select xx; return partialview(y); } public actionresult indexpall() { var y = xx in etljobs xx.etat == "completed" select xx; return partialview(y); }
if server not in web farm (multiple servers) can cache data in asp.net cache (this not output cacheing, it's data cacheing). set 5 minute time limit on expiration of data (you data needs update every 5 minutes) when controller needs data first checks cache, , if it's not there execute stored procedure.
mydata items; items = (mydata)cache["mydata"]; if(items == null) { items = doquerytoreturnitems(); cache.add("mydata", items, null, datetime.now.addminutes(5), ..); }
it's possible setup cache item dependent upon sqldependency when data changes, cache can updated.
Comments
Post a Comment