disadvantages of singleton model for caching?

  • Thread starter Thread starter Duncan Welch
  • Start date Start date
D

Duncan Welch

I'm creating a new C# app to mirror a legacy ASP app. I've created a data
access layer (DAL) which uses the singleton model to "emulate" the old
Application Variable caching except as a stand-alone DLL - it only reads
from the database infrequently changing information once a day.

Can anyone tell me if there will be a performance/usage penalty to using it
for my entire DAL? Or should I only be using the Singleton-model DAL class
for my "cached" information?

Thanks in advance,

Duncan
 
Duncan,

You shouldn't see a performance penalty, as long as your app is running
in one application domain (which it should be).

My only suggestion is that you make sure that calls to it are
thread-safe, using the lock statement to lock critical sections of code.

If you are going to have a high volume of reads to writes, then you
might want to look at the ReaderWriterLock class, which can manage this for
you, in a more efficient manner.

Hope this helps.
 
Back
Top