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