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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:55:19+00:00 2026-05-27T11:55:19+00:00

I want to program the basic CRUD operations of caching (creating new object ,

  • 0

I want to program the basic CRUD operations of caching (creating new object , remove it , update…) i start by creating the object and displaying its name this is my code:
(My cache name=”default”)

web.config:

..........

<configuration>
<configSections>
<section name="dataCacheClient"
   type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
    Microsoft.ApplicationServer.Caching.Core,
    Version=1.0.0.0,  Culture=neutral,PublicKeyToken=31bf3856ad364e35" />
     </configSections>
     <dataCacheClient>
      <hosts>
        <host name="Amira-PC" cachePort="22233" />

        </hosts>
       </dataCacheClient>

         ......

Global.asax.cs :

     using Microsoft.ApplicationServer.Caching;

      namespace AppFabricCachingTest{
        public class Global : System.Web.HttpApplication
         {
         public static string CacheFactoryName = "CacheFactory";
          void Application_Start(object sender, EventArgs e)
          {
        // Code qui s'exécute au démarrage de l'application


        var dcf = new DataCacheFactory();
        Application[CacheFactoryName] = dcf;
        DataCache myCache = dcf.GetCache("default");// cache name=mycache

        object myCachedItem = new Object();
        string myCachedItemKey = "MyCacheKey";
        myCache.Add(myCachedItemKey, myCachedItem);



     }
    .....

     `  

Site.Master.cs

       `  
        using Microsoft.ApplicationServer.Caching;

         namespace AppFabricCachingTest
       {
           public partial class SiteMaster : System.Web.UI.MasterPage
               {
           protected void Page_Load(object sender, EventArgs e)
              {

                }

    public string GetCachedName()
     {
       string name = null;
       string key ="MyCacheKey";

        var dcf = Application[Global.CacheFactoryName] as DataCacheFactory;

          if (dcf != null)
            {
    var cache = dcf.GetCache("default");
    name = cache.Get(key) as string;
    if (name == null)
    {
        name = "Windows Server App Fabric Cache ";
        cache.Put(key, name);

    }
    else
    {
        name += " From Cache!";

            }
             }
        else name = "dcf is NULL";
           return name;
       }

         }
     }

Site.Master :

 <body>
        <form runat="server">
             <div class="page">
                <div class="header">
                   <div class="title">
            <h1>
               <%= GetCachedName() %>
            </h1>
        </div>
            ...............

After running I got always “The dcf is NULL” and not the name of the object
Any idea please,

Thank you in advance

  • 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-27T11:55:20+00:00Added an answer on May 27, 2026 at 11:55 am

    I think you’re missing declaration of other object as part of DataCacheFactory initialization.
    The DataCacheFactory does not know, where it should gather cluster cache from.
    Please try the below code

    DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];
    servers[0] = new DataCacheServerEndpoint(“localhost”, 22233);

    // Setup the DataCacheFactory configuration.

    DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
    factoryConfig.Servers = servers;

    // Create a configured DataCacheFactory object.

    DataCacheFactory cacheFactory = new DataCacheFactory(factoryConfig);

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

Sidebar

Related Questions

I want to achieve basic CRUD operations available of the db schema I already
I am creating a program using Visual Basic 2010 Express . I want to
I want my program to change its window's caption in response to various user
Im using Plato3 to write C programs. Im creating a menu-driven program but want
I have written a program in visual basic and want it to display the
I want to compile a very basic hello world level Cuda program under Linux.
I am creating a C# program that outputs text to a file. I want
I am implementing basic socket program , but in this case i want the
In a Visual Basic 6.0 program, I have a string sTemp that I want
I am creating a very basic encryption program using XOR to encrypt a user

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.