On Mon, Mar 2, 2009 at 12:56 PM, Dan <[email protected]> wrote:

>
> Hi everyone,
>
> I'm trying to create some lazy querying classes in my code to minimize
> the number of queries run per request.  Suppose, for example, I wanted
> to store all the comments on a site in a variable, cached_comments,
> which is part of an application, Blog.  (Note, I'm not actually doing
> anything this silly, but my work is confidential so this serves as an
> illustrative but silly example.)
>
> So Blog.cached_comments is lazy and will only run a query to get the
> data if (a) it hasn't run the query yet, (b) something tries to access
> it.  If someone adds a new comment, a function,
> Blog.cached_comments.reset() is called which will set the state of
> cached_comments to 'query not run yet.'
>
> However, I'm a little confused, as it seems like as Apache runs
> multiple processes, there could be multiple copies of
> Blog.cached_comments floating around, each with differing data.  Is
> this correct?  I know this is more of a mod_python question, but I
> thought I'd ask it here as I'm not able to find the information I'm
> looking for and it seems like django might be using some similar
> structures to determine what fields in a form are changed.  Any help
> or readings that could be suggested would be greatly appreciated.
>
> Thanks,
> Dan
>
> >
>
Yes, this is correct, the best way to handle something like this is with a
real caching system that is seperate from your python processes,
specifically memcache.  Checkout the Django caching docs for how to use it
with Django.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to