locked
Making this static will cache the database instance after the initial load??????? RRS feed

  • Question

  • User-192792487 posted
    // Get a default instance of the database using the DatabaseFactory CreateDatabase method.
        // Making this static will cache the database instance after the initial load.

        private static readonly Database db = DatabaseFactory.CreateDatabase();

    I have this line of code in every class in my BLL. What does "making this static will cache the database instance after the initial load"

    Am I going to have "lots" of database instances in my cache? If so how long is the instance cached for???

    Cheers!

    N
    Wednesday, November 1, 2006 4:19 PM

All replies

  • User1001868398 posted

    I don't understand, static will be one instance, however in a page, does not mean will cache, if you want to cache do this:


     Database db = DatabaseFactory.CreateDatabase();

    Cache["db"] = db;

    Friday, November 3, 2006 3:28 PM