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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:07:25+00:00 2026-06-06T20:07:25+00:00

I have an application where every single page uses a set of data that

  • 0

I have an application where every single page uses a set of data that is stored in the database. To avoid making a call to the database every time I need the data, I decided to put it in HttpRuntime.Cache. I am making the call to the DB and caching the data in the constructor for my Controller.cs file, which is the only place this data is used.

The above method works, but I’m wondering if this is the correct place/way to load my cache?

Also, the data is the same for every user and will change maybe a few times a year.

  • 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-06T20:07:26+00:00Added an answer on June 6, 2026 at 8:07 pm

    Caching the data, and consuming the cached data are two different concerns. Supposing you have this interface to fetch the data:

    public interface IDataRepository 
    {
        List<Data> GetData();
    }
    

    you can have two implementations, one fetching the data from the database, another just acting as a proxy and caching the data, if necessary:

    public class DataRepository : IDataRepository
    {
        public virtual List<Data> GetData()
        {
            //Hit the database and get the data
        }
    }
    
    public class CachedDataRepository : DataRepository, IDataRepository
    {
        public override List<Data> GetData()
        {
            if(!IsCachedAlready())
            {
                var data = base.GetData();
                AddToCache(data);
            }
    
            return DataFromCache();
        }
    }
    

    You can now use the same interface and not worry if the data that you’re use in the controller is cached or not.

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

Sidebar

Related Questions

I have a master page that needs to display some data from my database.
Here's what I have: A web application that runs in a single HTML page
I am working on single-page AngularJS application that doesn't have any backend but use
I have an application that I restart at 2 am every morning using Application.Restart();
I have an application that needs to check a website feed every second. Sometimes
We have a winforms application calling a stored procedure every few seconds. The stored
I have an android application that displays a toast every hour and then every
We have a web application that is generating some 3-5 parallel threads every five
ColdFusion sets the CFID and CFTOKEN cookie on every single page, obviously connecting that
I have a custom error page in my MVC application that's just ~/error/ but

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.