ASP.NET Podcast Show #129 - Caching with .NET 3.5 SP1 - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? .NET, ADO.NET, ASP.NET, AJAX, Atlas, Microsoft AJAX Library, ASP.NET AJAX, and now Windows Azure............follow me on twitter at Wally

ASP.NET Podcast Show #129 - Caching with .NET 3.5 SP1

 

Subscribe to All!

Subscribe to WMV.

Subscribe to M4V (iPod).

Subscribe to MP3.

Download WMV.

Download M4V (iPod).

Download MP3.

Original Url: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2008/12/04/asp-net-podcast-show-129-caching-with-net-3-5-sp1.aspx

Show Notes:

  • New Caching Support in .NET 3.5 SP1.

Source Code:

    protected void Page_Load(object sender, EventArgs e)

    {

        string Output = String.Empty;

        if (!Page.IsPostBack)

        {

            lblOutput.Text = GetCacheItem();

        }

    }

 

    private string GetCacheItem()

    {

        string OutValue = String.Empty;

        if (Cache["Test"] != null)

        {

            OutValue = Convert.ToString(Cache["Test"]);

        }

        else

        {

            OutValue = DateTime.Now.ToString();

            Cache.Insert("Test", OutValue, null,

                DateTime.Now.AddSeconds(10),

                TimeSpan.Zero, OnUpdateCallback);

        }

        return (OutValue);

    }

    private void OnUpdateCallback(String key, CacheItemUpdateReason r,

        out Object ObjectToCreate, out CacheDependency CacheDependencies,

        out DateTime DateTimeExpire, out TimeSpan TimeSpanExpire)

    {

        ObjectToCreate = DateTime.Now;

        CacheDependencies = null;

        DateTimeExpire = DateTime.Now.AddSeconds(10);

        TimeSpanExpire = TimeSpan.Zero;

    }

 

Comments

No Comments
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems