#15149: Memcached backend: possible issue with cache keys
-----------------------------------------+----------------------------------
          Reporter:  j...@jeffcroft.com  |         Owner:  nobody   
            Status:  new                 |     Milestone:           
         Component:  Cache system        |       Version:  SVN      
        Resolution:                      |      Keywords:  memcached
             Stage:  Unreviewed          |     Has_patch:  0        
        Needs_docs:  0                   |   Needs_tests:  0        
Needs_better_patch:  0                   |  
-----------------------------------------+----------------------------------
Comment (by j...@jeffcroft.com):

 Thanks for your help, Russell. Updating my trunk didn't help. So I applied
 the path you provided, and got these results:

 {{{
 >>> from django.core.cache import cache
 >>> cache.clear()
 >>> cache.get('testing_yo')
 get base key = testing_yo
 get base version = None
 get key = lendle_:1:testing_yo
 get val = None
 >>> cache.set('testing_yo', 'testing, yo!', 300)
 >>> cache.key_prefix
 'lendle_'
 >>>
 >>> # Using Django's cache framework's get method - THIS IS THE REAL ISSUE
 >>> cache.get('testing_yo')
 get base key = testing_yo
 get base version = None
 get key = lendle_:1:testing_yo
 get val = None
 >>>
 >>> # Using the underlying memcached instance - THIS IS JUST HERE TO GIVE
 MORE INFO
 >>> cache._cache.get('testing_yo')
 'testing, yo!'
 >>> cache._cache.get('%stesting_yo' % cache.key_prefix)
 >>> cache._cache.get('%s:1:testing_yo' % cache.key_prefix)
 >>>
 }}}

 My cache settings are as follows:

 {{{
 CACHES = {
   'default': {
     'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
     'LOCATION': '127.0.0.1:11211',
     'KEY_PREFIX': 'lendle_',
   }
 }
 }}}

 And the memcached -vv output is thus:

 {{{
 <28 new auto-negotiating client connection
 28: Client using the ascii protocol
 <28 flush_all
 >28 OK
 <28 connection closed.
 <28 new auto-negotiating client connection
 28: Client using the ascii protocol
 <28 get lendle_:1:testing_yo
 >28 END
 <28 connection closed.
 <28 new auto-negotiating client connection
 28: Client using the ascii protocol
 <28 set testing_yo 0 300 12
 >28 STORED
 <28 connection closed.
 <28 new auto-negotiating client connection
 28: Client using the ascii protocol
 <28 get lendle_:1:testing_yo
 >28 END
 <28 connection closed.
 <28 new auto-negotiating client connection
 28: Client using the ascii protocol
 <28 get testing_yo
 >28 sending key testing_yo
 >28 END
 <28 connection closed.
 <28 new auto-negotiating client connection
 28: Client using the ascii protocol
 <28 get lendle_testing_yo
 >28 END
 <28 connection closed.
 <28 new auto-negotiating client connection
 28: Client using the ascii protocol
 <28 get lendle_:1:testing_yo
 >28 END
 <28 connection closed.
 }}}

 From all of this, it's clear to me that the cache is getting set with the
 key "testing_yo", not "lendle_:1:testing_yo". But I can't, for the life of
 me, figure out why.

 Thanks again for all your help.

 P.S. You'll notice that I switched projects, here -- from barstar to
 lendle, but the results are the same, either way.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15149#comment:8>
Django <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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to