Bit of a rambling, thinking-out-loud-ish post... Whilst it's conceivable some cache backend will have the smarts to multiplex requests on a single connection, I suspect that's more the exception than the case.
However, that doesn't mean the cache backend can't be left with the opportunity to manage per-thread connections. Obviously, the default would be one per thread. The situation is complicated with the "ad-hoc config" option. Otherwise, each cache backend could have a factory method, where the cares of thread locality can be managed. You'd just tell it the name, and it would take care of the rest. Of course, that could be simplified by just always creating a new instance when more than just a name is provided. [or a "force new" keyword is passed]. -- Curtis On 1 September 2013 22:24, Florian Apolloner <f.apollo...@gmail.com> wrote: > Hi, > > > On Sunday, September 1, 2013 4:34:54 AM UTC+2, Curtis Maloney wrote: >> >> I've a possible solution - https://github.com/funkybob/** >> django/compare/simple_caches<https://github.com/funkybob/django/compare/simple_caches> >> >> Basically, the existing API and behaviours are still available through >> get_cache, but you can avoid duplicate instances of caches using >> django.core.cache.caches[name] >> > > As noted on the ticket (https://code.djangoproject.com/ticket/21012), I > think this needs some more brainstorming (preferably on this ml) before we > introduce a new pulbic API to access a cache. My main concern is: does it > even make sense to share the cache connection between threads? eg what > happens if two threads want to read a value from the cache, will one thread > block till python-memcached returned the value for the other thread? > > Cheers, > Florian > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at http://groups.google.com/group/django-developers. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. For more options, visit https://groups.google.com/groups/opt_out.