Google Groups Home
Help | Sign in
Message from discussion GSoC 2007 - Object-Level Caching
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Gary Wilson  
View profile
 More options Jun 26 2007, 1:54 am
From: Gary Wilson <gary.wil...@gmail.com>
Date: Tue, 26 Jun 2007 00:54:46 -0500
Local: Tues, Jun 26 2007 1:54 am
Subject: Re: GSoC 2007 - Object-Level Caching
Getting back into the swing of things...

Paul Collier wrote:
>> If I update o1 in some other part of the
>> code, what assumptions are made about qs?
> Hmm, yeah... I haven't focused enough attention on .cache_set() yet,
> heheh. I was definitely just going to implement (1) first, and then
> worry about something more advanced once I got to the "smart"
> functionality (which I might just be making default behaviour now). At
> some point I'll be writing a class with which cached queries register
> so that pre/post_save signals can freshen the cache; that's should
> lightweight enough to scale by itself, but to implement (3) I guess
> it'd also have to track which PKs are present. I'm not really sure if
> (2) is desirable.

I could see how (2) would be desirable if you are expecting
qs.cache_set() to work like cache.set('myqs', qs), which is how I
interpreted your proposal.  Though, I could also understand someone
wanting one of the other implementations too.

So what were your implementation thoughts about cache_set()?  It appears
that you did not mean for it to simply be a shortcut for doing
cache.set('my_qs', qs).  Could you please clarify this?

As far as cache correctness and the pre_save/post_save signals for
refreshing/invalidating the cache, there is sill the possibility of
objects in the database getting altered outside of the currently-running
django instance.  In this case, your cache won't be correct, even with
going through all the trouble of trying to keep it updated.  This is
where I think option (2) is the desired choice again, for simplicity and
explicitness.  Objects are cached until they timeout or until I
explicitly refresh them.  Thoughts?

Also, all this object caching seems to me like something that would tie
in nicely to the models themselves.  Maybe something similar to the
ModelAdmin class of newforms-admin.  Cache refreshing/invalidating
behavior could even be an option if it is implemented.

class Author:
     name = CharField()

class AuthorCacheOptions(cache.ModelOptions):
     # Cache Author objects?
     cache = True
     # How long to cache Author objects?
     seconds = 3600
     # Try to keep cached objects in sync with database?
     # If False, cached objects are not updated until they expire.
     sync = True

Now, Author query sets using .cache() would use the AuthorCacheOptions
by default when no parameters are passed.

Gary


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google