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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:48:41+00:00 2026-05-30T09:48:41+00:00

I have successfully started using Azure AppFabric Caching Service, but I’ not sure what

  • 0

I have successfully started using Azure AppFabric Caching Service, but I’ not sure what the best practice way of creating the DataCacheFactory object is. Now I’m creating it for every call into the cache, but apparently this is not the ideal way of doing it…

Some advise call for a Singleton. But I’m not sure I understand how this would be implemented (not the actual Singleton class, but how to tie it all together).

Today I have a CacheProvider class that is created for me using Ninject where I can do Get/Put/Remove operations. For each of these methods I create the DataCacheFactory object and then call .GetDefaultCache() to get the DataCache object, where I call Put/Get/Remove respectively. I do this in a single method that looks like this:

private T Cache<T>(Func<DataCache, T> cacheAction)
{
    using (DataCacheFactory dataCacheFactory = new DataCacheFactory())
    {
        DataCache dataCache = dataCacheFactory.GetDefaultCache();
        return cacheAction(dataCache);
    }
}

I’m now pretty sure that this is not-so-clever-idea, I should instead be getting the DataCache object via a Singleton where the DataCacheFactory object is just created once. BUT how will that object survive between requests? And how does that work with > 1 instance on Azure?

Hope all this makes sense and that somebody with more experience than me (3 hours) can help me out.

  • 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-30T09:48:42+00:00Added an answer on May 30, 2026 at 9:48 am

    Singleton objects live at the application scope. Simply declare your private DataCache object on a global static level, provide a property Get that instantiates the object if it is null or returns the object if it is not null.

    This way, you will be paying the cost of instrumenting configuration and connection of the cache only once per application recycle.

    Each instance will instantiate its own DataCache object and it is ok.

    The actual data, where the cache is stored is not stored on your local machine’s memory, but in Azure’s dedicated cache servers that are distributed and mega-fast.

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

Sidebar

Related Questions

I have started using asp.net MVC and as traditional way I want to keep
I've started using Doxygen to document my team's project source code (we have C#,
I am using gettext for a large PHP project. I have successfully setup everything,
I have been successfully using boost::spirit::qi to to parse a stream consisting of the
I have just started using SlickGrid and was hoping someone can help me solve
Recently I started using https://github.com/crowdint/rails3-jquery-autocomplete It works great, but I was trying to set
Just started using carrierwave with Rails and things have been going smoothly with one
I have an application that I've been using xVal successfully on for quite some
I have started using jquery in one of my new asp.net webform application... I
I have just started using maven-glassfish-plugin. I got the start-domain goal working. However when

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.