Does the USE directive load a new instance of the object per request? Or is
it cached?

I'm trying to speed up a legacy app that uses TT (which is new to me). I
discovered the app was making numerous identical database calls to retrieve
the authenticated user's info.

Each template includes the line [% USE Util; %] at the top -- it's this
class where the user info is retrieved. I modified Util.pm so that it
checks to see if it already has a user property, checks to make sure the
user property contains the same username as the requested user, and if so
returns that instead of generating a database call.

This drops the load time by 75%, but I am concerned that the change may
introduce a race condition. If 2 users request the page at the same time
and the Util object is shared, it's possible that user A's info could be
returned to user B, or vice-versa.

Thanks in advance,
Chris

-- 
Chris Herdt
Web Applications Developer
http://osric.com/chris/
_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to