I think it should be stored in the instance of the user for each request, rather than in the session. In large sites with lots of users, the memory usage for sessions could grow to be too large. Since each request has only one instant of the sfUser class then you can store the guardUser, permissions, etc. all in that instance of the user, and making multiple calls to the getGuardUser() will result in only one query always for each request.
This approach is kind of a middle ground between saving memory and lowering the number of database queries. You can see how I did it in this function.. http://jwage.pastebin.co.uk/14446 - Jon Oriol Mercadé wrote: > Hello group, I have a dilema... > > I've seen that sfGuard pluggin, makes a query each time you call > hasCredential() [when it is logged and it is not superadmin] > I've seen also that everyTime that getGuardUser() is called, it also > leads to a query... > > Do you think it is a good idea to store the sfguard user object in > session? i know it is an object and therefore it is not recommended > but, it is an object with little information and it causes one query > per request when the user is validated in the system, > > I have the credentials already stored in the session, and if I update > a credential of a user in the bd i refresh the information in the > session too, so merging credential in session and sfGuardUser in > session may avoid one query to the bd in each request. > > What do you think? > > > An other more philosophical question is... what number of db queries > do you think should not be done? > I know that a request that generates N queries where N is the number > of iterations of something is not tolerable, but what about 3 queries > per request? and 5? 10? > what does your experience in production enviorements say? > thank you very much in advance! > > -- > - Oriol Mercadé Figueras > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en -~----------~----~----~----~------~----~------~--~---
