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

  • SEARCH
  • Home
  • 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 7742065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:11:19+00:00 2026-06-01T09:11:19+00:00

I have code to add item to cache: public static void AddTask(string name, string

  • 0

I have code to add item to cache:

public static void AddTask(string name, string value,int seconds)
{
   _onCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
   HttpRuntime.Cache.Insert(name, value, null,
                        DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
                        CacheItemPriority.NotRemovable, _onCacheRemove);
}

For example, seconds equals 120. After 20 seconds I want to set expiration time again 120 seconds. How can I do this?

PS. A can’t delete this item and add again.

  • 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-06-01T09:11:21+00:00Added an answer on June 1, 2026 at 9:11 am

    When you add the item to the cache – you can provide a callback that is to be invoked when the runtime is about to remove the item from the cache – rather than your current one which gets called when it’s already been removed.

    In that callback, you can cancel the remove process and extend the entry’s lifetime.

    See this overload of insert and this documentation about the CacheItemUpdateCallback delegate

    Although you’re already handling the removed event – this ‘updated’ event is basically the same thing – it just gives you the ability to cancel the expiration if need be.

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

Sidebar

Related Questions

I have this code for adding: public void add(AnyType item){ if(isEmpty()){ q[f]=item; } else{
I have code like the following: class MyClass { string Name; int NewInfo; }
I have the following code: SPList list = web.Lists[this.ListName]; SPListItem item = list.Items.Add(); now
I have this code: foreach (var item in ListView1.Items) { ListView1.Items.Remove(item); ListView21.Items.Add(item); } the
I have following code which add BackButton on my view's navigation item's tabbar. It
I have a subclass of UITableViewController. I have code that can add/remove a UISearchBar
I have this quickBox2d code to add a cricle to the stage: var ball:QuickObject
i have the follow code: searchResults.SearchResultCollection.Add( new SearchResult() { Header = HttpUtility.HtmlDecode( htmlDocument.DocumentNode .SelectSingleNode(initialXPath
I have a piece of C# code that add the values of an enum
I have a code-base that I'm looking to split up and add to by

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.