c# - How to store (cache?) data across multiple sessions in ASP.NET -
i'm writing c# asp.net web form application. keep brief, application retrieves data server , displays users.
to access server, application needs generate login info. generating login info takes several minutes. login info changes daily, it's same who's using application (on particular day).
my application used hundreds of people daily. it's silly me make each user wait several minutes login info retrieved.
ideally, i'd gather login info once day, , store results somewhere on server.
any tips? know .net has cache , session, store data 1 individual user. have techniques storing login info can grab code-behind?
you wrong, cache works in application level, not in user level, msdn
an application can increase performance storing data in memory accessed , requires significant processing time create. example, if application processes large amounts of data using complex logic , returns data report accessed users, efficient avoid re-creating report every time user requests it. similarly, if application includes page processes complex data updated infrequently, inefficient server re-create page on every request.
to increase application performance in these situations, asp.net provides caching using 2 basic caching mechanisms. first application caching, allows cache data generate, such dataset object or custom report business object. second page output caching, saves output of page processing , reuses output instead of re-processing page when user requests page again.
i think application cache fits better other one
about expire
there 2 ways control it, can set x minutes limit, , set if want :
absolute: expire data after x minutes since object created
cache.insert("key", mytimesensitivedata, null, datetime.now.addminutes(1), timespan.zero);
absolute expiration: example cache time sensitive data 1 minute, @ point cache expire. note absolute expiration , sliding expiration (below) cannot used together.
sliding: expire data after x minutes since last user used cache object
cache.insert("key",myfrequentlyaccesseddata, null, system.web.caching.cache.noabsoluteexpiration, timespan.fromminutes(1));
sliding expiration: example cache used data. data remain in cache until 1 minute passes without referencing it. note sliding expiration , absolute expiration cannot used together.
example source: msdn: caching api, using cache object
Comments
Post a Comment