Suggestions about caching the data in a static class RRS feed

  • Question

  • User-1368425629 posted

    Hi guys,

    I am working on an application which gets all its configuration details from the database and some from webconfig, so instead of making calls to the database each time i need these details i have created a static class which caches all these details. Although i think this  is the right way to do things as it will save me from repeated calls to the sql server. I still wanted some clarifications:

    1. I read some articles which say Static Classes are not threadsafe, does it mean that there could be a situation when the data gets corrupted on there could exist more then one instance of the class.

    2. I will be storing only strings and integers in this class but a lot of them so what are the costs in term of memory usage. Would there be any situation where multiple instances get created of the class... and so memory usage increases.

    3. If the info in the database changes and i want to update the info in this class, what happens to to the users who are currently accesing this data.

    4. Any other downsides anyone can suggest to this method

    Thanks a ton.

    Thursday, May 6, 2010 10:49 AM