On Jan 8, 2009, at 12:49 PM, Tycon wrote:
No having it as a global is much better then in a middleware, because setting up the global happens only once at process start-up time, but the middleware is called in every request. In the middleware you add it to the environment, which is again something that's newly created for every request, but the app-globals are only created once at process startup and remain for the duration of the process. You only want to put something in the per-request environment if it is something that's specific to that request, like the query string. A static global value like a reference to cache manager (the reference to that object doesn't change afte it's set up at startup) should not be in the middleware.
Oh, I see what you mean. The Beaker Cache object must be setup per- thread, as I don't believe the code in it is thread-safe to execute simultaneously across multiple threads. Other than that, yea, no need to keep setting it up over and over, and I always like optimizations like this. :)
There's a lot of Beaker Cache/NameSpace/Container code that all assumes its being used just once in one thread, so a new Cache object would need to be made for every thread that runs, but after that, no more Cache object creations.
Can you file a ticket for this so I don't forget it? It won't make it in time for 0.9.7, but for 1.0, definitely.
Cheers, Ben
smime.p7s
Description: S/MIME cryptographic signature
