#5: Add a cache=NUM_SECONDS argument to QuerySet
------------------------+---------------------------------------------------
   Reporter:  adrian    |                Owner:  adrian                
     Status:  reopened  |            Component:  Metasystem            
    Version:            |           Resolution:                        
   Keywords:            |                Stage:  Design decision needed
  Has_patch:  0         |           Needs_docs:  0                     
Needs_tests:  0         |   Needs_better_patch:  0                     
------------------------+---------------------------------------------------
Changes (by [EMAIL PROTECTED]):

 * cc: [EMAIL PROTECTED] (added)

Comment:

 It would be nice to be able to plug Django into something like
 [http://www.danga.com/memcached/ Memcache] and turn on caching, but I
 would like to see it ''above'' the database layer rather than ''below''
 it.
 {{{
 try:
     polls = memcache.get('polls_blah')
 except CacheNotFound:
     polls = Polls.objects.all()
     memcache.set('polls_blah', list(polls), memcache.FIFTEEN_MINUTES)
 }}}
 
 Putting caching into the database layer IMHO adds too much magic, and
 could produce weird results when cache behavior is unexpected.  Forcing
 the app developers to use a cache explicitly keeps them "in the know"
 about what they're doing.  There could even be a Django shortcut like
 {{{
 polls = get_cached('polls_blah', lambda: Polls.objects.all(),
 cache.FIFTEEN_MINUTES)
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5#comment:5>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to