General discussion

Locked

Caching

By coolmanohar ·
How to remove a cache variable on application close in asp.net

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by BFilmFan In reply to Caching

Explicit removal on an object from cache example below:

<script language=C# runat=server>
public void Application_OnStart()
{
System.IO.StreamReader sr =
new System.IO.StreamReader("pi.txt");
string pi = sr.ReadToEnd();
Context.Cache.Add("pi", pi, null,
Cache.NoAbsoluteExpiration,
new TimeSpan(0, 5, 0),
CacheItemPriorityDecay.Never,
new CacheItemReomovedCallback(this.OnRemove));
}
public void OnRemove(string key, object val, CacheItemRemovedReason r)
{
// respond to cache removal here
}
</script>

Setting an absolute expiration for a page in the output cache example below:

<%@ OutputCache Duration="3600" VaryByParam="none" %>
<html>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e) {
msg.Text = DateTime.Now.ToString();
}
</script>
<body>
<h3>Output Cache example</font></h3>
<p>Last generated on: <asp:label id="msg" runat="server"/>
</body>
</html>

I think you will need to overview these conference materials for further details:
http://www.develop.com/conferences/conferencedotnet/materials/A9.pdf

Also there are several ASP.NET forums on the Microsoft Forum pages.

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums