public CachedRoute(string controller, string action, string cacheKey, ICachedRouteDataProvider <TPrimaryKey> dataProvider, IRouteHandler handler) { if (string.IsNullOrWhiteSpace(controller)) { throw new ArgumentNullException("controller"); } if (string.IsNullOrWhiteSpace(action)) { throw new ArgumentNullException("action"); } if (string.IsNullOrWhiteSpace(cacheKey)) { throw new ArgumentNullException("cacheKey"); } if (dataProvider == null) { throw new ArgumentNullException("dataProvider"); } if (handler == null) { throw new ArgumentNullException("handler"); } this.controller = controller; this.action = action; this.cacheKey = cacheKey; this.dataProvider = dataProvider; this.handler = handler; // Set Defaults CacheTimeoutInSeconds = 900; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ICachedRouteDataProvider <int> cachedRouteDataProvider, IMemoryCache memoryCache) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseMvc(routes => { routes.Routes.Add(new CachedRoute <int>( controller: "category", action: "index", dataProvider: cachedRouteDataProvider, cache: memoryCache, target: routes.DefaultHandler) { CacheTimeoutInSeconds = 900 }); routes.MapRoute( name: "default", template: "{controller=home}/{action=index}/{id?}"); }); }
public CachedRoute( string controller, string action, ICachedRouteDataProvider <TPrimaryKey> dataProvider, IMemoryCache cache, IRouter target) { if (string.IsNullOrWhiteSpace(controller)) { throw new ArgumentNullException("controller"); } if (string.IsNullOrWhiteSpace(action)) { throw new ArgumentNullException("action"); } if (dataProvider == null) { throw new ArgumentNullException("dataProvider"); } if (cache == null) { throw new ArgumentNullException("cache"); } if (target == null) { throw new ArgumentNullException("target"); } _controller = controller; _action = action; _dataProvider = dataProvider; _cache = cache; _target = target; // Set Defaults CacheTimeoutInSeconds = 900; _cacheKey = "__" + this.GetType().Name + "_GetPageList_" + _controller + "_" + _action; }
public CachedRoute(string controller, string action, ICachedRouteDataProvider <TPrimaryKey> dataProvider) : this(controller, action, typeof(CachedRoute <TPrimaryKey>).Name + "_GetMap_" + controller + "_" + action, dataProvider, new MvcRouteHandler()) { }