Figured this out now. The problem is that Django automatically prepends 
':1:' to the key, where 1 is the VERSION setting from the CACHES dict. 

I didn't think this was made particularly clear in the documentation when I 
first went through it but sure enough, it is quite clearly stated here:
https://docs.djangoproject.com/en/1.4/topics/cache/#cache-versioning

The solution for me was to use the KEY_FUNCTION setting to provide my own *
make_key* function.

Note to self and future readers of this: up the logging verbosity of 
memcache to *-vvv *to get useful level of logging.

On Thursday, June 20, 2013 6:00:04 PM UTC+1, Max Vizard wrote:
>
> Hi there,
>
> I'm having some issues with the low level cache functionality in Django 
> 1.4 and I can't seem to find info relevant to my exact problem.
>
> I'm running a separate Python script to check on the status of a Master 
> and Slave MySQL db pair, which then inserts some values into a local 
> Memcache instance.
> I know for certain that the values are being inserted into the cache, as I 
> can access them from another Python interpreter using pylibmc.
>
> However, when I try to access those same keys from a Django view, the 
> results are None. I've configured the CACHES setting to point at the same 
> local 
> Memcache instance and tried with both django.core.cache.MemcachedCache and 
> django.core.cache.PyLibMCCache.
>
> Perhaps my understanding is flawed and Django shouldn't be able to access 
> cache values inserted by another process? I would think that this is not 
> the case because otherwise the use of such a cache would be quite limited.
>
> I haven't checked that Django can write to the cache and read back for 
> itself yet, that is a task for tomorrow.
>
> Any thoughts or input is much appreciated.
>
> Thanks,
> Max
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to