Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:07:23+00:00 2026-05-27T08:07:23+00:00

Our application adds objects to the cache using the following int cacheTimeout = 5;

  • 0

Our application adds objects to the cache using the following

int cacheTimeout = 5; // Default 5 minute timeout
if(ConfigurationManager.AppSettings["CacheTimeout"] != null)
{
    cacheTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CacheTimeout"].ToString());
}
_cache.Insert(Key, CacheItem, null, DateTime.MaxValue, new TimeSpan(0, cacheTimeout, 0));

Our manager is concerned about possible caching issues and wants to know, what happens if you insert an object with a 0 length time span.

I think the object will be immediately deleted. Right or wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:07:24+00:00Added an answer on May 27, 2026 at 8:07 am

    Answer is “Wrong”.

    When inserted into the cache with the absolute expiration set to NoAbsoluteExpiration and the sliding expiration set to new TimeSpan(0,0,0), the callback is not fired immediately. I didn’t wait to see when it would fire, if ever – maybe it’s 20 minutes, maybe it’s never.

    So changed the code to this:

    int cacheTimeout = 5; // Default 5 minute timeout
    if(ConfigurationManager.AppSettings["CacheTimeout"] != null)
    {
        cacheTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CacheTimeout"].ToString());
    }
    TimeSpan expiration = cacheTimeout > 0 ? new TimeSpan(0,cacheTimeout,0) : new TimeSpan(0,0,1);
    _cache.Insert(Key, CacheItem, null, System.Web.Caching.Cache.NoAbsoluteExpiration, expiration, CacheItemPriority.Default, OnUpdateCallback);
    

    That way if we do have caching problems we can update web.config to set the cache time out to 0 and have a 1 second expiration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following situation: I'm developing an address-application to store the details of our
Our application adds and removes WPF (4.0) UserControls from it's main window, and we've
In our web application, I am allowing users to edit their profiles, using a
Our application is mining names from people using Twitter to login. Twitter is providing
Our application is sending our emails with Word attachments using System.Net.Mail. We have empty-string
Our application uses bunch of WMI calls. When using guest account connecting to local
Our application can get following numbers: 0.1 0.02 0.003 etc. These values treated by
Our application is interfacing with a lot of web services these days. We have
Our application is a hybrid Win32 unmanaged application and a .NET 2.0 managed application.
Our application has a file format similar to the OpenDocument file format (see http://en.wikipedia.org/wiki/OpenDocument

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.