Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
ASP.NET Podcast Show #129 - Caching with .NET 3.5 SP1 - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, Xamarin.iOS, Xamarin.Android, and Windows Azure.

News

Visual Studio Magazine Column Personal Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

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

xoro said:

# December 4, 2008 4:25 PM