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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:03:27+00:00 2026-06-13T19:03:27+00:00

I was asked to build different WCF services where each do other work against

  • 0

I was asked to build different WCF services where each do other work against sql.

We have 5 db’s. All db’s+connection string are in 1 xml file. ( file-system file)

The services are hosted under WAS iis 7.5.

since each service should read from db , each service references a DAL dll file.

So here are our components :

enter image description here

I would like to read the xml data to CACHE ( at the first request) and from now on – read from cache. (reading the file each reqeust is out of the question).

  • idea #1 = the dll , in his ctor , at first request will read the xml file and load it to its cache.

so the dal will look like this :

enter image description here

so now each service can access the DLL’s cache object via property. ( one advantage is when dealing with cache dependency on a single file – so when it is changing , we should reload only to one location).

  • idea #2 = when service is up , load the xml into its cache.

so now , each service will look like this :

Service #1 :

enter image description here

Service #2 :

enter image description here

..

the downside is many cache dependencies on the same file

Question :

By the best practice experience and by design pattern POV : which is the preferred way ?

p.s. the xml file change frequency 1/(1 month)

  • 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-13T19:03:29+00:00Added an answer on June 13, 2026 at 7:03 pm

    First of all, when it comes to file system, on Windows Server OS, there’s a built in cache layer above the disk. So you probably won’t feel much difference regarding disk reads. Of course, parsing the same input again and again is not a good practice, so the parsed (tokenized) xml should be cached.

    The design needs more clarifications:

    1. Is there only a single instance of a DAL class, shared among the 5
      services? Or maybe the property described in idea 1 is static?

    2. In idea 2: when the file changes and, say, connection string 4 is
      changed (and everything else remains the same) – only service 4
      should be reloaded?

    3. If a specific service is reloaded – does it cause some kind of
      inconsistency with other (non fresh) services?

    Update:

    I’m still not sure I fully understand the scenario, but here’s what I’d do as far as I understand:

    The DAL should expose an interface for all data related operations.

    Let’s say it’s IDataGateway

    Now, each service has should have a reference to an instance that implements IDataGateway. The service should not be aware of the caching mechanism at all. It just consumes data from the interface.

    So all of the caching is done outside the service, in terms of classes and code organization.

    Now, the caching layer, in turn, implements IDataGateway, and also consumes a non cached instance of IDataGateway. That’s called Decorator pattern. The non cached instance is to be injected in the constructor.

    Now, I suggest each service has its own instance of a cached IDataGateway. It’s simpler than a singleton (to me, at least). And since data is not shared between services, then we’re cool. If, however, data is shared between the services, than a single instance should be used.

    Back to those 5 instances, and to the xml file.

    We want to monitor this file once it changes, right? We could easily write our own file monitor, or use the one that comes with the framework, or we could see the source code of the CacheDependency class.

    The simplest way to do it is to have 5 monitors watching the same file. That’s not much of a performance penalty, since timers are quite “cheap”.

    If, however, you’d like to reduce the resources being used by your system, then you could use a single monitor, having it raise its event of FileChanged or something like that. Each of the 5 cached implementations (those 5 instances) of IDataGateway should have this monitor injected in its constructor, and wire up its own event listener to the FileChanged event.
    Once this event is triggered, all of the 5 cached instances of IDataGateway would invalidate their inner cache, thus they should clear their in-memory entries.

    On the next call, the cached implementation of IDataGateway would try to take the non existing data from its in-memory cache, but obviously nothing would be there, so it should go on executing the same method in the non-cached implementation of IDataGateway, and populate its cache.

    That’s my design, HTH…

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

Sidebar

Related Questions

I have been asked to build a web application that will be used to
I have been asked to build an app that lets the user scroll massive
Other people have asked similar questions but I want to clarify. I want to
build.xml contains <scp> and <sshexec> tasks, so I provide jsch.jar and other libraries in
I was asked to build a java system that will have the ability to
I have been asked to build a small web application for one of our
I have been asked by a client if it was possible to build a
This question is related to two different questions I have asked previously: 1) Reproduce
This question has been asked in many different ways out there, but I have
So, this question has been asked lots, and i have seen many different answers,

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.