Instead of over complicating it like this. Why not just use memcached or
django's own cache?

On Thu, Jun 12, 2008 at 11:45 AM, Juan Hernandez <[EMAIL PROTECTED]>
wrote:

> Hey there, I have a question concerning performance and best practices
>
> I have this piece of code in one of my views
>
> =====
> # query execution
> def db():
>         return bp.objects.all()
>
> def title():
>         x = db()
>         y = x[0].title
>         return y
>
> def blogSubtitle():
>         return bp.objects.all()[0].blogSubtitle
> =====
>
> What I'm trying to do is: Having my methods go to the DB only once and then
> getting everything from memory but I don't think I'm accomplishing that. I
> get all the records in the query() method and then, title for example, uses
> it and gets what it want and the blogSubtitle() goes directly and makes
> another query . My question is: if I use the title() method, everytime I
> call the query() method, it would be executing another query right? just as
> if I was executing that query inside the method. I've seen many examples in
> the documentation and I haven't been able to figure the best way to do it. I
> just want to execute a big query once and then, get everything from memory
> without going back to the db.
>
> Thanx
> jhv
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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