[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

PERMANENTLY add something to Cache

How do I add something that will live in the Cache permanently?
This object will be added to cache when application is started and should exist until the application is closed.

Thanks.
0
smacca
Asked:
smacca
1 Solution
 
dfu23Commented:
http://samples.gotdotnet.com/quickstart/aspplus/doc/datacaching.aspx

You can set a datetime to expire ... make it always set to something really far out like 20 years from now and that should work ... I'm sure other methods could be used too.
0
 
RogerSTHLMCommented:
You can use the "old fashioned way", application("aNameForYourObject")=[your object]
0
 
RejojohnyCommented:
use global.asax file's application on_start event to set the cache .. and as dfu23 has suggested .. set the expiry to 20 years or so ... also set the priority to "NotRemovable" so that it never gets removed from the cache
this will add a dataset to the cache for 20 years and it will never get removed until the application is restarted .. ...
        Cache.Insert("MyKey", MyDataset, null, DateTime.Now.AddYears(20), TimeSpan.Zero, Caching.CacheItemPriority.NotRemovable)

and if u add the above line in global.asax onstart .. it will ensure that it is always re-created when the application starts ...

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now