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 6192801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:00:30+00:00 2026-05-24T03:00:30+00:00

In my application I have used a generic handler to serve requests. I want

  • 0

In my application I have used a generic handler to serve requests.

I want a mechanism like, if the first time request comes to the handler, it makes a request to the server and then caches the whole datatable, so for upcoming requests if the next requested productcode exists in the cached datatable, it should not go to the server for fetching data again; it should check the data of the cached datatable only.

How can I set up a datatable in the cache?

  • 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-24T03:00:31+00:00Added an answer on May 24, 2026 at 3:00 am

    Something along these lines?

    public DataTable GetDataTableFromCacheOrDatabase()
    {
       DataTable dataTable = HttpContext.Current.Cache["secret key"] as DataTable;
       if(dataTable == null)
       {
           dataTable = GetDataTableFromDatabase();
           HttpContext.Current.Cache["secret key"] = dataTable;
       }
       return dataTable;
    }
    

    You’re going to need some mechanism to flush the data table from the cache if it changes. For example you could use an SqlCacheDependency.

    As requested, to clear the cache an hour after the table is added you would do:

    HttpContext.Current.Cache.Insert("secret key", dataTable, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see an application have used Log.info = some info where are these logs
I'm working on a Phonegap application.I have used header for every page. But when
I have integrate draw line in my application i have not used OpenGL or
i have developed application for read information from card reader. Here i have used
I have used AsyncTasks with my application, in order to lazy download and update
i have used impersonation in this application. whenever this error occurs i required to
i have used progress bar in my application..my application is working fine but the
I have used geocoder in my ruby on rails application for a while but
I have used Spring OXM and JiBX in my application. below is my Spring
I have used spring MVC with JSP/JSTL for my previous application. I was going

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.